Regex sheet
Regex... a second mystery for me.
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule
^ => Start by : ^(A)
..$ => End point of the match
(one word) (one second)
([0-9]{4})-([0-9]{1,2}) => one word of 4 digits which contains a number between 0 and 9
=> following another word 1 max 2 digits which contains a number between 0-9
. Any character
Grey|gray = means or, either grey or gray
gray|grey and gr(a|e)y
colou?r matches both "color" and "colour" =? replace one character
? match 0 or 1 time Quantifier
ab*c matches "ac", "abc", "abbc", "abbbc" => repeat the character which is before the star, 0 to unlimited
* match 0 to infinite times Quantifier
ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac" =>no zero
+ match atleast 1 or more times Quantifier ->the character before
=> repeat the character which is before the star, 1 to unlimited
a.c matches "abc" and acc adc aec =>replace every letter
[a.c] matches only "a", ".", or "c".
[^a-z] matches any single character that is not a lowercase letter from "a" to "z".
[^b]at matches all strings matched by .at except "bat".
^[hc]at matches "hat" and "cat",
a\{3,5\} matches only "aaa", "aaaa", and "aaaaa".
^/images/[:alnum:]{1,10}/[:alnum:]{1,10}(.*) http://localhost/images/[:alnum:]{1,10}(.gif|.jpg|.png)
<[A-Za-z][A-Za-z0-9]*> matches an HTML tag without any attributes
/php/i => upercase or lowercase
\ Use before any of the following characters to escape or null the meaning or it. \* \. \$ \+ \[ \]
() starts a back reference point
[] Starts a class
^ Negates the class. [^A-Z]+ means don't match any uppercases
\ Use before any of the following characters to escape or null the meaning or it. [\+]+
- Range for matching [0-9]+ [a-zA-Z]+
[R] Redirect you can add an =301 or =302 to change the type.
[F] Forces the url to be forbidden. 403 header
[G] Forces the url to be gone 401 header
[L] Last rule. (You should use this on all your rules that don't link together)
[N] Next round. Rerun the rules again from the start
[C] Chains a rewrite rule together with the next rule.
[T] use T=MIME-type to force the file to be a mime type
[NS] Use if no sub request is requested
[NC] Makes the rule case INsensitive
[QSA] Query String Append use to add to an existing query string
[NE] Turns of normal escapes that are default in the rewriterule
[PT] Pass through to the handler (together with mod alias)
[S] Skip the next rule S=3 skips the next 3 rules
[E] E=var sets an enviromental variable that can be called by other rules