Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Most languages are case-sensitive, so keywords can only be written with the rules of the keyword (case-sensitive), and the Regular Expression (RE) which describes the lexemen is very simple

Most languages are case-sensitive, so keywords can only be written with the rules of the keyword (case-sensitive), and the Regular Expression (RE) which describes the lexemen is very simple

Computer Science

Most languages are case-sensitive, so keywords can only be written with the rules of the keyword (case-sensitive), and the Regular Expression (RE) which describes the lexemen is very simple. However, some languages such as SQL are not case sensitive, so keywords can be written in lowercase or uppercase, or in any mixture of letters. So, the SQL SELECT keyword can also be written "select", "Select", or "sElEcT".

Question

Explain how to write a Regular Expression to accept keywords but is not case-sensitive.

(You can create it by providing examples of Regular Expressions for the introduction of certain keywords)

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Solution: A Regular Expression is nothing but an efficient way to implement logic. With the help of regular expressions, the implementation of logic is reduced by a very large size. For instance, if implementation takes around four to five lines of code in a function, the same logic can be implemented using the regular expressions in one line of code. Code for a regular expression to accept keywords without concerning about their case-sensitiveness is implemented using the Python programming language and is provided down below, please find attached the code and the screenshot for the same.

Code:

import re
print (re.search('timbaktoo', 'TimBAkToO', re.IGNORECASE))
print (re.match('timbaktoo', 'TIMbaktOo', re.IGNORECASE))

PFA

Related Questions