Regular Expressions used in htaccess

by Rekha 2010-02-17 14:12:56

Regular Expressions used in htaccess
1. Patterns ("wildcards") are matched against a string
2. Normal alphanumeric characters are treated as normal
3. Special characters:

* . (full stop) - match any character
* * (asterix) - match zero or more of the previous symbol
* + (plus) - match one or more of the previous symbol
* ? (question) - match zero or one of the previous symbol
* \? (backslash-something) - match special characters
* ^ (caret) - match the start of a string
* $ (dollar) - match the end of a string
* [set] - match any one of the symbols inside the square braces.
* (pattern) - grouping, remember what the pattern matched as a special variable

Examples:

* a+ matches "a", "aaaa", "aaaaaaaaaaaa", but not "bbb"
* [ab]+ matches, "a", "b", or any length combination of the two
* \.s?html? matches ".htm", ".shtm", ".html" or ".shtml"
* (.+)/1999/(.+) matches "subject/1999/psy1011/", and also stores "subject" in $1 and "psy1011/" in $2.

Tagged in:

1300
like
0
dislike
0
mail
flag

You must LOGIN to add comments