Linux regex case insensitive

 

We can use regex as case sensitive or insensitive as we wish. By default is is case sensitive.

To switch regex as case insensitive:

Use pattern (?i)  for case insensiteve.

Example:

$ echo Aab | perl -p -e "s/(?i)a//g"

output: b,  since we used (?i) both a and A replaced.

To switch regex as case sensitive:

Use pattern for (?-i) – for case insensiteve.

Sany

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s