Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make regex case insensitive? [duplicate]

Tags:

regex

If I am matching a word in a regex 'Strict-Transport' how can I make it case insensitive? Is there any way other than putting the two character cases [Ss] for each character because it is not about the initials, but all the characters can come in any case?

I looked at previous posts but there are not like my case. This post for example shows how to make regex case insensitive when using list of characters []. But my case is a word in regex.

like image 815
user9371654 Avatar asked May 11 '19 23:05

user9371654


People also ask

How do I make Regexmatch not case sensitive?

Case-Sensitive Match To disable case-sensitive matching for regexp , use the 'ignorecase' option.

How do you repeat in regex?

A repeat is an expression that is repeated an arbitrary number of times. An expression followed by '*' can be repeated any number of times, including zero. An expression followed by '+' can be repeated any number of times, but at least once.


1 Answers

You can use i modifier to make regex case-insensitive, e.g.:

(?i)ab

will match ab, Ab, aB and AB

like image 103
Kirill Polishchuk Avatar answered Oct 28 '22 11:10

Kirill Polishchuk