(a) Regex CRASH Course! (Pt. 1)

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: (a) Regex CRASH Course! (Pt. 1)

Post by prometheuzz »

GeertDD wrote:
d11wtq wrote:

Code: Select all

 
Character         Matching
 
. (dot)           ANY single character at all
 

Code: Select all

 
Modifier         Effect
 
s                Ignore whitespace
 
Note that the above is not quite true.

The dot metacharacter does match any single character except for newlines.

I don't know exactly what you mean by 's modifier ignores whitespace'? Anyway, the s modifier just changes the meaning of the dot metacharacter which will then match newlines as well. Agree?
You're right of course Geert. Note that the author's "ignores white space (in the regex)" remark should belong to the x-modifier.

Some more inaccuracies:

Code: Select all

\d, \s etc are what we refer to as "metacharacters"
Should be '\d, \s etc are what we refer to as "short hand character classes"'. Meta characters are: ., *, (, {, [, etc.
\d is a shorthand for [0-9], and [0-9] is a character class (or character set), hence: "short hand character class".

Code: Select all

\w Any single alphanumeric character (a-z, 0-9) and underscores
Should be: "\w Any single alphanumeric character (a-z, A-Z, 0-9) and underscores"

Code: Select all

[x-y] Any single character in the range x to z (e.g. [A-Z])
A typo, I presume: this should be "[x-y] Any single character in the range x to y (e.g. [A-Z])"
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: (a) Regex CRASH Course! (Pt. 1)

Post by prometheuzz »

batfastad wrote:This is a great tutorial. I refer to it all the time.

However I think I've found one slight inaccuracy regarding the s modifier which could be updated.

...
Geert already mentioned that. But I don't think this tutorial is updated anymore since is has last been updated in 2005...
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: (a) Regex CRASH Course! (Pt. 1)

Post by alex.barylski »

Chris...this is probably the best regex resource I have ever found...I refer to this more than anything when it comes to regex...

The only exception would be when I had to support Unicode...have you considered re-writting it to cover Unicode techniques?

Here is a useful resource I have also used several times:

http://www.regular-expressions.info/unicode.html

Cheers,
Alex
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: (a) Regex CRASH Course! (Pt. 1)

Post by prometheuzz »

PCSpectra wrote:Chris...this is probably the best regex resource I have ever found...I refer to this more than anything when it comes to regex...
It would have been better if the errors were removed from it.
PCSpectra wrote: Here is a useful resource I have also used several times:

http://www.regular-expressions.info/unicode.html
That is a better resource, IMHO.
soul_fly
Forum Newbie
Posts: 22
Joined: Mon Aug 24, 2009 2:24 pm

Re: (a) Regex CRASH Course! (Pt. 1)

Post by soul_fly »

simply awesome tutorial. I need that earlier. :)
remshad
Forum Newbie
Posts: 5
Joined: Tue Nov 24, 2009 4:58 am

Re: (a) Regex CRASH Course! (Pt. 1)

Post by remshad »

prometheuzz wrote:
batfastad wrote:This is a great tutorial. I refer to it all the time.

However I think I've found one slight inaccuracy regarding the s modifier which could be updated.

...
Geert already mentioned that. But I don't think this tutorial is updated anymore since is has last been updated in 2005...
definitely i also loved this tutorial ...!
akhilesh1010
Forum Newbie
Posts: 15
Joined: Thu Aug 22, 2013 1:56 am

Re: (a) Regex CRASH Course! (Pt. 1)

Post by akhilesh1010 »

excellent stuff thanks Chris.
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Re: (a) Regex CRASH Course! (Pt. 1)

Post by hybris »

Chris, if i were a girl I'd wanted you as father of my children :D

Thanks, excellent crash course! Finally I understand (or atleast think I understand) some of how the patterns work. Very helpful!

Cheers :)
Post Reply