Regular Expression

4.9K posts

Regular Expression banner
Regular Expression

Regular Expression

@RegexTip

Learn to use regular expressions by following RegexTip. From @JohnDCook.

Katılım Kasım 2009
19 Takip Edilen74.4K Takipçiler
Regular Expression
Regular Expression@RegexTip·
If you're going to work with regular expressions, it's worthwhile to learn Perl notation even if you don't intend to ever use Perl.
English
0
0
6
939
Regular Expression
Regular Expression@RegexTip·
You can include comments inside a regex with (?# ... ). For example, /the\s+(?# One or more spaces)end
English
0
0
4
899
Regular Expression
Regular Expression@RegexTip·
[a-z] matches all lower case letters. [-az] matches '-', 'a', or 'z'.
English
0
1
7
965
Regular Expression
Regular Expression@RegexTip·
Perl stores the content of the previous match in $&, the text to the left of the match in $`, and the text to the right in $'.
English
0
0
4
796
Regular Expression
Regular Expression@RegexTip·
If a dash is the first or last character in a character class, it is a literal dash and does not indicate a range.
English
0
0
4
1.1K
Regular Expression
Regular Expression@RegexTip·
'Perl Best Practices' recommends always using /xms on regexes. /x to allow whitespace & comments, /m and /s to handle newlines as expected.
English
0
0
2
909
Regular Expression
Regular Expression@RegexTip·
vi and vim's engine uses \+ and \= in place of the more common + and ?.
English
0
0
4
1.1K
Regular Expression
Regular Expression@RegexTip·
*, +, and ? are considered greedy quantifiers. They are going to consume matching tokens before moving on to the next atom.
English
0
0
4
884
Regular Expression
Regular Expression@RegexTip·
"I define UNIX as '30 definitions of regular expressions living under one roof.'" — Donald Knuth
English
1
1
9
1.5K
Regular Expression
Regular Expression@RegexTip·
Parentheses have the side effect of capturing, setting \1 to the stuff matched by the first set of parentheses, \2 to the second, etc.
English
0
0
3
844
Regular Expression
Regular Expression@RegexTip·
Parentheses and | denote options. Example: /(red|green|blue) truck/ matches 'red truck' or 'green truck' or 'blue truck'.
English
0
2
8
1.4K
Regular Expression
Regular Expression@RegexTip·
Reminder: * means zero or more, + means one or more, ? means zero or one.
English
0
1
8
811