vinpkl — 2012-09-27T11:53:53-04:00 — #1
i know ([a-zA-Z]+) matches any characters lower or uppercase
But i would like to what do these below 2 signs means and what do they match ?
cpradio — 2012-09-27T12:12:06-04:00 — #2
First one also matches underscores (the _ )
Second one also matches underscores (the _ ) and the hypen (the - )
vinpkl — 2012-09-27T12:18:59-04:00 — #3
is _ underscore sign optional in ([a-zA-Z_]+)
cpradio — 2012-09-27T12:21:04-04:00 — #4
All of them are optional.
The + simply means one of the characters in found between  needs to be found for the expression to be true, but it will capture all matching characters until the end or a non-matching character is found.\
To put that into perspective, the following will be captured
vinpkl — 2012-09-27T12:22:29-04:00 — #5
for the clarification
vinpkl — 2012-09-27T13:15:37-04:00 — #6
one more question :
whats the difference in (.*) and (.+)
cpradio — 2012-09-27T14:59:52-04:00 — #7
The first is for matching any character zero or more times, the latter is matching any character 1 or more times
cpradio — 2012-09-27T15:00:25-04:00 — #8
If you want an AWESOME book for Regular Expressions, I recommend O'Reilly Regular Expression Pocket Reference
scallioxtx — 2012-09-27T15:19:55-04:00 — #9
Also, regex basics are quite nicely explained on http://www.regular-expressions.info/
A lot of stuff I know about regex I got from there.
dklynn — 2012-09-27T18:46:58-04:00 — #10
You really should add that Apache advises that the metacharacter (within a character range definition), the "-", should be the first character within the range definition so it can be understood to be the character (rather than the metacharacter used to define a range of characters). Under common usage, however, Apache accepts the - as the last character in the range (as vineet has in his code snippet).
WARNING: The references to the regex book and article are fine but mod_rewrite only uses a rather small and very basic subset of regex BECAUSE the Apache variables are not multi-line, they are not formatted (italic, bold, etc) and they must fit the format of the variable as required by Apache. That makes learning the subset used by mod_rewrite a relatively trivial task.
As for the definitive book on regex, let me recommend what most consider the bible on this subject: Jeffrey Friedl's "Mastering Regular Expressions" which is published by O'Reilly.
cpradio — 2012-09-27T18:53:32-04:00 — #11
The reason I suggested the O'Reilly Regular Expression Pocket Reference is because it actually teaches you the regular expression syntax used by various languages (I think apache may be in there too, but I don't quite remember and my book is on my work desk). So you can see the C# implementation, versus PHP, Perl, Java, etc. It is very handy when you are trying to nail down a regular expression and can't quite remember some of the oddities a language may have implemented.
Even though this is in the URL Rewriting forum, I didn't want to assume it was meant for Apache, versus maybe .NET URL Rewrite, or just a regular expression to be used for some other purpose.