regex - regular expression match case sensitive off -


i have regular expression finds 2 words in line.

the problem is case sensitive. need edit matches both case.

reqular expression

^(.*?(\bpain\b).*?(\bfever\b)[^$]*)$ 

you can use regexoptions.ignorecase set case insensitive matching mode. way make the entire pattern case insensitive. same effect can achieved (?i) inline option @ beginning of pattern:

(?i)^(.*?(\bpain\b).*?(\bfever\b)[^$]*)$ 

you can use inline flag set case insensitive mode part of pattern:

^(.*?(\b(?i:pain)\b).*?(\b(?i:fever)\b)[^$]*)$ 

or can match "pain" or "pain" with

^(.*?(\b(?i:p)ain\b).*?(\bfever\b)[^$]*)$ 

another alternative using character classes [pp], etc.

note not have set capturing group round whole pattern, have access via rx.match(str).groups(0).value.

^.*?(\b[pp]ain\b).*?(\b[ff]ever\b)[^$]*$ 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -