/** * Sets this Pattern's flags with the char-per-flag representation of regex flags. Removes flags set earlier. * The flag string should consist of letters 'i','m','s','x','u','X'(the case is significant) and a hyphen or plus. * The meaning of letters: * <ul> * <li><b>i</b> - case insensitivity, corresponds to REFlags.IGNORE_CASE;</li> * <li><b>m</b> - multiline treatment(BOLs and EOLs affect the '^' and '$'), corresponds to REFlags.MULTILINE flag;</li> * <li><b>s</b> - single line treatment('.' matches \r's and \n's),corresponds to REFlags.DOTALL;</li> * <li><b>x</b> - extended whitespace comments (spaces and eols in the expression are ignored), corresponds to REFlags.IGNORE_SPACES.</li> * <li><b>u</b> - predefined classes are regarded as belonging to Unicode, corresponds to REFlags.UNICODE; this may yield some performance penalty.</li> * <li><b>X</b> - compatibility with XML Schema, corresponds to REFlags.XML_SCHEMA.</li> * <li><b>-</b> - turn off the specified flags; normally has no effect unless something adds the flags.</li> * <li><b>+</b> - turn on the specified flags; normally is no different from just using the letters.</li> * </ul> * @param flags a String that stores various flags as chars */ public void setFlags(String flags) { internalCompile(stringRepr, parseFlags(flags)); }
/** * Sets this Pattern's flags with the char-per-flag representation of regex flags. Removes flags set earlier. * The flag string should consist of letters 'i','m','s','x','u','X'(the case is significant) and a hyphen or plus. * The meaning of letters: * <ul> * <li><b>i</b> - case insensitivity, corresponds to REFlags.IGNORE_CASE;</li> * <li><b>m</b> - multiline treatment(BOLs and EOLs affect the '^' and '$'), corresponds to REFlags.MULTILINE flag;</li> * <li><b>s</b> - single line treatment('.' matches \r's and \n's),corresponds to REFlags.DOTALL;</li> * <li><b>x</b> - extended whitespace comments (spaces and eols in the expression are ignored), corresponds to REFlags.IGNORE_SPACES.</li> * <li><b>u</b> - predefined classes are regarded as belonging to Unicode, corresponds to REFlags.UNICODE; this may yield some performance penalty.</li> * <li><b>X</b> - compatibility with XML Schema, corresponds to REFlags.XML_SCHEMA.</li> * <li><b>-</b> - turn off the specified flags; normally has no effect unless something adds the flags.</li> * <li><b>+</b> - turn on the specified flags; normally is no different from just using the letters.</li> * </ul> * @param flags a String that stores various flags as chars */ public void setFlags(String flags) { internalCompile(stringRepr, parseFlags(flags)); }
/** * Compiles a regular expression using Perl5-style flags. * The flag string should consist of letters 'i','m','s','x','u','X'(the case is significant) and a hyphen or plus. * The meaning of letters: * <ul> * <li><b>i</b> - case insensitivity, corresponds to REFlags.IGNORE_CASE;</li> * <li><b>m</b> - multiline treatment(BOLs and EOLs affect the '^' and '$'), corresponds to REFlags.MULTILINE flag;</li> * <li><b>s</b> - single line treatment('.' matches \r's and \n's),corresponds to REFlags.DOTALL;</li> * <li><b>x</b> - extended whitespace comments (spaces and eols in the expression are ignored), corresponds to REFlags.IGNORE_SPACES.</li> * <li><b>u</b> - predefined classes are regarded as belonging to Unicode, corresponds to REFlags.UNICODE; this may yield some performance penalty.</li> * <li><b>X</b> - compatibility with XML Schema, corresponds to REFlags.XML_SCHEMA.</li> * <li><b>-</b> - turn off the specified flags; normally has no effect unless something adds the flags.</li> * <li><b>+</b> - turn on the specified flags; normally is no different from just using the letters.</li> * </ul> * * @param regex the Perl5-compatible regular expression string. * @param flags the Perl5-compatible flags. * @throws PatternSyntaxException if the argument doesn't correspond to perl5 regex syntax. * see REFlags */ public Pattern(String regex, String flags) throws PatternSyntaxException { internalCompile(regex, parseFlags(flags)); }
/** * Compiles a regular expression using Perl5-style flags. * The flag string should consist of letters 'i','m','s','x','u','X'(the case is significant) and a hyphen or plus. * The meaning of letters: * <ul> * <li><b>i</b> - case insensitivity, corresponds to REFlags.IGNORE_CASE;</li> * <li><b>m</b> - multiline treatment(BOLs and EOLs affect the '^' and '$'), corresponds to REFlags.MULTILINE flag;</li> * <li><b>s</b> - single line treatment('.' matches \r's and \n's),corresponds to REFlags.DOTALL;</li> * <li><b>x</b> - extended whitespace comments (spaces and eols in the expression are ignored), corresponds to REFlags.IGNORE_SPACES.</li> * <li><b>u</b> - predefined classes are regarded as belonging to Unicode, corresponds to REFlags.UNICODE; this may yield some performance penalty.</li> * <li><b>X</b> - compatibility with XML Schema, corresponds to REFlags.XML_SCHEMA.</li> * <li><b>-</b> - turn off the specified flags; normally has no effect unless something adds the flags.</li> * <li><b>+</b> - turn on the specified flags; normally is no different from just using the letters.</li> * </ul> * * @param regex the Perl5-compatible regular expression string. * @param flags the Perl5-compatible flags. * @throws PatternSyntaxException if the argument doesn't correspond to perl5 regex syntax. * see REFlags */ public Pattern(String regex, String flags) throws PatternSyntaxException { internalCompile(regex, parseFlags(flags)); }
mLen = p - mOff; if (mLen > 0) { flags = Pattern.parseFlags(data, mOff, mLen); flagsChanged = true; break mLoop; case ')': flags = Pattern.parseFlags(data, mOff = (i + 2), mLen = (p - mOff)); flagsChanged = true; ttype = FLAGS;
mLen = p - mOff; if (mLen > 0) { flags = Pattern.parseFlags(data, mOff, mLen); flagsChanged = true; break mLoop; case ')': flags = Pattern.parseFlags(data, mOff = (i + 2), mLen = (p - mOff)); flagsChanged = true; ttype = FLAGS;