I wish to find a regex which matches all combination of the word if. So the valid ones are :
iF, IF , If and if
I have a regex here: [iIfF]*
Eventhough it is matching what I want, it is matching the word Fi and other such combinations too.
Where I'm making the mistake?
Since you seem to be using Java, you'd want:
Pattern p = Pattern.compile("if", Pattern.CASE_INSENSITIVE);
[iI][fF]
Everything in the brackets in any combination will be allowed.
EDIT Java allows for case insensitive RegEx
"(?i)if"
would suffice
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With