Regular expressions
Regular expressions are a logical formula for manipulating strings. We generally use regular expressions to match and filter strings. Pros and cons of using regular
Advantages: Flexible, strong function, strong logic
Cons: Difficult to get started
Regular expressions are composed of and metacharacters characters. Ordinary characters include uppercase and lowercase letters, numbers
Partial meta-characters
1 character groups are used when [] is enclosed in [] and the contents of [] appear to be matched by more than one word-for example [0-9]
2
. Match any character other than line break
\w Match alphanumeric underline
\s matches any whitespace character
\d Matching numbers
\ nthe match line break
\b Matches the end of a word
^ Start of matching string
$ matches the end of a string
\w matches non-uppercase and lowercase letters, numbers
\d matches non-numeric
\s matching non-whitespace characters
A|b match character A or b
() matches the expression in parentheses, and also represents a group
[....] Match characters in a character group
[^...] Match all characters except characters in a character group
3. quantifier
* Repeat 0 or more times
+ Repeat one or more times
? Repeat 0 or one time
{n} repeats n times
{n,} repeats n or more times
{N,m} repeats n to M times
Common Modules 3