7/13 Table 1. Overview of Perl's Regex-Related Items ++++++++++++++++++++++++++++++++++++++++++++++++ Regex-Related Operators m/ regex / mods (see Section 7.4.3) s/ regex / replacement / mods (see Section 7.6) qr/ regex / mods (see Section 7.4) split(ááá) (see Section 7.7) ModifiersModify How . . . /x /oregex is interpreted(see Section 7.2.3, Section 7.9.1) /s /m /iengine considers target text (see Section 7.2.3) /g /c /eother (see Section 7.5.3.3, Section 7.5.4.4, Section 7.6.2) Related Pragmas use charnames 'full';(see Section 7.2.1.1) use overload;(see Section 7.8.6) use re 'eval';(see Section 7.8.3) use re 'debug';(see Section 7.9.6) After-Match Variables (see Section 7.3.3) $1, $2, etc.captured text $^N $+latest/highest filled $1, $2, . . . @- @+arrays of indices into target ---------------------------------------------------------- $' $& $'text before, of, and after match (best to avoidÑsee "Perl Efficiency Issues" Section 7.9.3.3) Related Functions lc lcfirst uc ucfirst (see Section 7.2.1.1) pos (see Section 7.5.4.1) quotemeta (see Section 7.2.1.1) reset (see Section 7.5.1.4) study (see Section 7.9.4) Related Variables $_default search target (see Section 7.5.2.1) $^Rembedded-code result (see Section 7.3.3) JAVA++++ public class SimpleRegexTest { public static void main(String[] args) { String sampleText = "this is the 1st test string"; String sampleRegex = "\\d+\\w+"; java.util.regex.Pattern p = java.util.regex.Pattern.compile(sampleRegex); java.util.regex.Matcher m = p.matcher(sampleText); if (m.find()) { String matchedText = m.group(); int matchedFrom = m.start(); int matchedTo = m.end(); System.out.println("matched [" + matchedText + "] from " + matchedFrom + " to " + matchedTo + "."); } else { System.out.println("didn't match"); } } }