Shell Regular Expressions
- Last Updated: August 5, 2025
- 1 minute read
- LoadMaster
- LoadMaster GA
- Documentation
Regular expressions can be used to craft complex matching and replacing rules. The Match String can be a Shell Regular Expression, which is a type of statement that matches or excludes based on the strings. An asterisk (*) in a Shell Regular Expression means “match all”.
A Shell Regular Expression is a sequence of characters. Any character, which is not a special character, matches itself. The following special characters are defined.
|
Character |
Meaning |
|---|---|
| ^ |
This can only be placed at the start of the string and means that the string must match at the start of the URL |
| $ |
This can only be placed at the end of the string and means that the string must match at the end of the URL |
| ? |
This matches any single character |
| * |
This matches zero or more characters |
| [ |
This starts the set notation. This matches a single character which is contained within a set. If the set starts with ^, then this matches a single character which is not within the set |
Shell Regular Expression Examples
Some examples of Shell Regular Expressions are below:
- [0-9] matches any single digit
- [^abf] matches any character, which is not “a”, “b” or “f”
- ^/[^a-z] matches any first character in the URL which is not a small letter
- home/*.gif matches any URL which points to a .gif file in the /home directory
- [gG][iI][fF] matches any URL which contains the string “gif”, “GIF”, “gIF”, “giF”, “GiF”, and so on.