2017年6月11日 星期日

Regular Expression Quick Guide

Metacharacter Description
^ Matches the beginning of a line
$ Matches the end of the line
. Matches any character
\s Matches whitespace
\S Matches any non-whitespace character
* Repeats a character zero or more times
*? Repeats a character zero or more times(non-greedy)
+ Repeats a character one or more times
+? Repeats a character one or more times(non-greedy)
[aeiou] Matches a single character in the listed set
[^XYZ] Matches a single character not in the listed set
[a-z0-9] The set of characters can include a range
(pattern) Defines a marked subexpression to extract
(?:pattern) Defines a marked subexpression not to extract
x|y Matches any one of several subexpressions
? Matches the preceding subexpression zero or one time
{n} Matches the preceding subexpression n times
{n,} Matches the preceding subexpression at least n times
{n,m} Matches the preceding subexpression at least n and not more than m times

Assertion Lookbehind Lookahead
Positive (?<=pattern) (?=pattern)
Negative (?<!pattern) (?!pattern)


regex101
https://regex101.com/

沒有留言:

張貼留言