Israel Science and Technology Directory

InternetApache server

Regular expression (Regex) symbols used in htaccess
SymbolsFunction
^Caret - Marks the Start of input.
Ex: ^a matches "a" at the start of input.
$Dollar sign - Marks the end of input.
Ex: b$ matches a "b" at the end of input.
.Dot - Matches a single character except newline.
*Asterisk - Matches the preceding character zero or more times.
Ex: ^.*$ matches the entire input.
?Matches the preceding character zero or one time.
+Matches the preceding character one or more times.
o+ would match o, ooo, ooo, etc.
[]Square brackets define a character set to match a single character.
Ex: [d-f] or [def] both match "d", "e" or "f".
[^]Caret in square brackets - Negation symbol.
Ex: [^0-9] matches any non digit character.
()Parentheses - Define a group of characters that is remembered.
The expression can be recalled using $num, where num = 1..n.
a{n}Curly brackets - Number (n) of the preceding character to be matched.
Ex: a{2,3} matches "aa" or "aaa".
Signals not to perform an action.
!Defines negation.
|Logical ‘OR‘ operator.
Ex: (a|b|c)a matches "aa" or "ba" or "ca".