Oh, mom, it hurts----regular expression
The regular is used to handle complex text types.
Standard Character Set:
\d---> stands for 0-9 any number \d----> any character except the number \w-----> Letter (case) number, underline full match \w-----> all characters except alphanumeric underscore
\s-----> spaces, line breaks, tabs
\s-----> All characters except the Space wrap tab
. -----> match any character except line break
Custom Character Set (* *)
Use the [] match method, match the characters within [], use ^ in [] to indicate the inverse -to indicate from which to which interval
[[email protected]]-----> match the characters of Q or P or 3 or @
[A-f]------> match characters between a-f
[^a-v0-7]----> matches characters in addition to A-v 0-7
Use of quantifiers: special symbols for modifying the number of matches
{n}----> expression repeats n times
\D{6}: Match 6 digits
{\d\d} {6}: Match 12 digits
{M,n}----> expression repeats at least m times, the maximum repetition n times is greedy mode, if there are N times will continue to append n times
{m,n}? -----> Repeat M-times, non-greedy mode
{m,}-------> at least m times, m+ is counted
? ---------> Match Expression 0 or one time equals {0,1}
A/d?b: Match AB a5b
+----------> At least one time equals {1}
A/d+b: Matching a2b a34b
* ----------> is equivalent to {0}
Character bounds: is the position, not the character
^------> Character Start place
^o: string starting with O
$------> where the string ends
o$: string ending with O
\b------> Not all is/w's expression.
qw\b: Only this QW 123QW is configured
Mobile phone number Matching
1[358]\B{9} starts with------1, and the 2nd bit can be 3.5.8 Other 9 digits
Mailbox match
[\w\-] [Email protected] [A-za-z0-9]+ (\.[ a-za-z]{2,5}) {}
Common regular matches
Java uses the regular:
Create a regular expression and matcher two objects using the Pattern under the Java.util package
Pattern p= pattern.compile ("\\d"); To create a regular expression
MATCHR m =p.matcher ("ddeff34");//need to match the regular
while (M.find ()) {
M.group ();//Remove
}
Java Regular expression (regular)