Example: stock market

Java Regular Expressions Cheat Sheet - …

Metacharacters([{\^$|)?*+.Character Classes[abc]a, b, or c (simple class)[^abc]Any character except a, b, or c (negation)[a-zA-Z]a through z, or A through Z, inclusive (range)[a-d[m-p]]a through d, or m through p: [a-dm-p] (union)[a-z&&[def]]d, e, or f (intersection)[a-z&&[^bc]]a through z, except for b and c: [ad-z] (subtrac-tion)[a-z&&[^m-p]]a through z, and not m through p: [a-lq-z] (sub-traction)Predefined Character character (may or may not match line terminators)\dA digit: [0-9]\DA non-digit: [^0-9]\sA whitespace character: [ \t\n\x0B\f\r]\SA non-whitespace character: [^\s]\wA word character: [a-zA-Z_0-9]\WA non-word character: [^\w]QuantifiersGreedyReluctantPossessiv eMeaningX?]}

Metacharacters ([{\^$|)?*+. Character Classes [abc] a, b, or c (simple class) [^abc] Any character except a, b, or c (negation) [a-zA-Z] a through z, or A through Z ...

Tags:

  Sheet, Teach, Expression, Java, Regular, Java regular expressions cheat sheet

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Java Regular Expressions Cheat Sheet - …

1 Metacharacters([{\^$|)?*+.Character Classes[abc]a, b, or c (simple class)[^abc]Any character except a, b, or c (negation)[a-zA-Z]a through z, or A through Z, inclusive (range)[a-d[m-p]]a through d, or m through p: [a-dm-p] (union)[a-z&&[def]]d, e, or f (intersection)[a-z&&[^bc]]a through z, except for b and c: [ad-z] (subtrac-tion)[a-z&&[^m-p]]a through z, and not m through p: [a-lq-z] (sub-traction)Predefined Character character (may or may not match line terminators)\dA digit: [0-9]\DA non-digit: [^0-9]\sA whitespace character: [ \t\n\x0B\f\r]\SA non-whitespace character: [^\s]\wA word character: [a-zA-Z_0-9]\WA non-word character: [^\w]QuantifiersGreedyReluctantPossessiv eMeaningX?]}

2 X??X?+X, once or not at allX*X*?X*+X, zero or more timesX+ X+?X++X, one or more timesX{n}X{n}?X{n}+X, exactly n timesX{n,}X{n,}?X{n,}+X, at least n timesX{n,m}X{n,m}?X{n,m}+X, at least n but not more than m timesBoundary Matchers^The beginning of a line$The end of a line\bA word boundary\BA non-word boundary\AThe beginning of the input\GThe end of the previous match\ZThe end of the input but for the final terminator, if any\zThe end of the inputClass Pattern FieldsCANON_EQEnables canonical case-insensitive whitespace and comments in dotall multiline Unicode-aware case Unix lines Matcher Methodsstatic Pattern compile(String regex)Compiles the given Regular expression into a Pattern compile(String regex, int flags)Compiles the given Regular expression into a pattern with the given flags()

3 Returns this pattern's match matcher(CharSequence input)Creates a matcher that will match the given input against this Boolean matches(String regex, CharSeq input)Compiles the given Regular expression and attempts to match the given input against pattern()Returns the Regular expression from which this pattern was [] split(CharSequence input)Splits the given input sequence around matches of this [] split(CharSequence input, int limit)Splits the given input sequence around matches of this Matcher MethodsMatcher appendReplacement(StringBuffer sb, String replacement)Implements a non-terminal append-and-replace appendTail(StringBuffer sb)Implements a terminal append-and-replace end()Returns the index of the last character matched, plus end(int group)Returns the index of the last character, plus one, of the subsequence cap-tured by the given group during the previous match find()Attempts to find the next subsequence of the input sequence that matches the find(int start)Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified group()Returns the input subsequence matched by the previous group(int group)Returns the input subsequence captured by the given group during the previous match groupCount()

4 Returns the number of capturing groups in this matcher's lookingAt()Attempts to match the input sequence, starting at the beginning, against the matches()Attempts to match the entire input sequence against the pattern()Returns the pattern that is interpreted by this replaceAll(String replacement)Replaces every subsequence of the input sequence that matches the pat-tern with the given replacement replaceFirst(String replacement)Replaces the first subsequence of the input sequence that matches the pattern with the given replacement reset()Resets this reset(CharSequence input)Resets this matcher with a new input start()Returns the start index of the previous start(int group)Returns the start index of the subsequence captured by the given group during the previous match J2SE Regular Expressions Cheat Sheet v 2005 Eric Stewart.

5 To donate visit


Related search queries