Sidebar

How can I do a case insensitive search with a regular expression?

0 votes
1.1K views
asked Oct 16, 2018 by rich-c-2789 (16,180 points)
I have a regular expression like "PID5.1=regex:/.*John.*/" however it
does not find message containing "johnson" or "That be you john?".  It
appears the default regex search is case sensitive.  Is there a way to
make it case insensitive?

1 Answer

0 votes

You can use an inline modifiers (also known as an embedded flags) that are
supported by Java regular expression syntax. 

To use modifiers/flags added them in the "contains" field with your regular expression.  To switch to a case insensitive search add the insensitive flag "i" to your regex like in this example:

(?i).*John.*

See screen shot:

See the JavaDoc for java.util.regex.Pattern for additional details on
Java regular expressions, and other modifiers/flags.

References:

    https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.
    html

See also:

    Can I use a regular expression to search within the content of messages?

    Is there list of Java regular expression errors, causes, solutions?

answered Oct 16, 2018 by rich-c-2789 (16,180 points)
edited Oct 19, 2018 by rich-c-2789
...