May 2009
Intermediate to advanced
510 pages
15h
English
You want to compile a regular expression with all of the available matching modes: free-spacing, case insensitive, dot matches line breaks, and caret and dollar match at line breaks.
Regex regexObj = new Regex("regex pattern",
RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase |
RegexOptions.Singleline | RegexOptions.Multiline);Dim RegexObj As New Regex("regex pattern",
RegexOptions.IgnorePatternWhitespace Or RegexOptions.IgnoreCase Or
RegexOptions.Singleline Or RegexOptions.Multiline)Pattern regex = Pattern.compile("regex pattern",
Pattern.COMMENTS | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE |
Pattern.DOTALL | Pattern.MULTILINE);Literal regular expression in your code:
var myregexp = /regex pattern/im;
Regular expression retrieved from user input, as a string:
var myregexp = new RegExp(userinput, "im");
regexstring = '/regex pattern/simx';
m/regex pattern/simx;
reobj = re.compile("regex pattern",
re.VERBOSE | re.IGNORECASE |
re.DOTALL | re.MULTILINE)Literal regular expression in your code:
myregexp = /regex pattern/mix;
Regular expression retrieved from user input, as a string:
myregexp = Regexp.new(userinput,
Regexp::EXTENDED or Regexp::IGNORECASE or
Regexp::MULTILINE);Many of the regular expressions in this book, and those that you find elsewhere, are written to be used with certain regex matching modes. There are four basic modes that nearly all modern regex flavors ...
Read now
Unlock full access