How to make the regex not case sensitive?

by elise_daugherty , in category: Third Party Scripts , 4 months ago

How to make the regex not case sensitive?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by daisha , 4 months ago

@elise_daugherty 

To make a regular expression (regex) not case sensitive, you can use the i flag after the regex pattern. For example, you can use the following syntax in JavaScript:

1
var regex = /pattern/i;


In this case, the i flag makes the regex pattern case insensitive, so it will match uppercase and lowercase letters without distinction.


Alternatively, you can also pass the i flag as a second argument when using the RegExp constructor:

1
var regex = new RegExp('pattern', 'i');


This will create a case-insensitive regex pattern as well.

Related Threads:

How to make webpack case sensitive?
How to deal with case sensitive files in git?
How to swap case with python regex?
How to make codeigniter uri case insensitive?
How to make username email case insensitive in symfony?
How to protect sensitive information in PHP scripts?