This link has been bookmarked by 252 people . It was first bookmarked on 24 May 2007, by Pistos Christou.
-
19 Dec 10
-
24 Jul 10
-
23 Jul 10
-
22 Jul 10
-
masumbuetThe absolute bare minimum every programmer should know about regular expressions - I’m Mike
-
21 Jul 10
-
20 Jul 10
-
26 Apr 10
-
22 Apr 10
-
04 Apr 10
-
16 Feb 10
-
The absolute bare minimum every programmer should know about regular expressions
-
The Line Anchors: ‘^’ and ‘$’
-
The ‘^’ character is used to anchor the match to the start of the line, so
^mikewould only find lines that start with mike. Similarly, the expressionmike$would only find m - i - k - e at the end of a line (but would still match ‘carmike’). -
The Character Class: ‘[]‘
-
The regular expression
gr[ea]yis interpreted as “g, followed by r, followed by either an e or an a, followed by y.” -
If you use
[^ ... ]instead of[ ... ], the class matches any character that isn’t listed. -
The Character Class Metacharacter: ‘-’
-
Instead of [01234567890abcdefABCDEF] we can write [0-9a-fA-F]
-
Matching Any Character With a Dot: ‘.’
-
The ‘.’ metacharacter (called a dot or point) is shorthand for a character class that matches any character.
-
The Alternation Metacharacter: ‘|’
-
For example,
MikeandMichaelare separate expressions, butMike|Michaelis one expression that matches either. -
The expression
Mi(ke|chael)matches the same thing. -
Matching Optional Items: ‘?’
-
If I wanted to match the english or american versions of the word ‘flavor’ I could use the regex
flavou?r -
The Other Quantifiers: ‘+’ and ‘*’
-
I might use the regular expression
go+al, which would match ‘goal’, as well as ‘gooooooooooooooooal’ (but not ‘gal’). -
The Interval Quantifier: ‘{}’
-
The regex
go{1,5}alwould limit our previous example to matching between one and five o’s. The sequence {0,1} is identical to a question mark. -
The Escape Character: ‘\’
-
if you would like to match the ‘?’ or ‘\’ characters, you can precede them with a backslash, which removes their meaning: ‘\?’ or ‘\\’.
-
Using Parenthesis for Matching: ‘()’
-
I could match the domain portion of a URL by using an expression like
http://([^/]+).
-
-
27 Dec 09
-
05 Nov 09
-
02 Nov 09
-
15 Sep 09
-
27 Aug 09
-
14 Aug 09
-
Greg Linch"Regular expressions are strings formatted using a special pattern notation that allow you to describe and parse text. Many programmers (even some good ones) disregard regular expressions as line noise, and it’s a damned shame because they come in handy s
programming tutorial reference regex development tutorials code coding howto regexp
-
10 Jul 09
-
17 Jun 09
-
15 Jun 09
-
07 Jun 09
-
05 Jun 09
The absolute bare minimum every programmer should know about regular expressions - I’m Mike
regex programming regexp tutorial reference development tutorials code
-
04 Jun 09
Ian GrayBrief and simple guide to regular expressions
regex Programming regexp tutorial reference tutorials howto expressions development code regular expressions
-
02 Jun 09
-
28 Apr 09
-
30 Jan 09
-
22 Dec 08
-
09 Nov 08
-
23 Oct 08
-
19 Sep 08
-
18 Sep 08
-
30 Aug 08
-
08 Jul 08
-
02 Jul 08
-
01 Jul 08
-
30 Jun 08
-
29 Jun 08
-
28 Jun 08
-
27 Jun 08
Page Comments
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.