## Regular Expressions

TopStyle's find and replace features support Regular Expressions (RE), which enable you to find or replace strings based on patterns. The following regular expression operators are supported:

a+ | One or more occurrences of a
a* | Zero or more occurences of a
a? | Zero or one (i.e. optional) occurence of a
a|b | Either a or b
a||b | a or b or both a and b in any order
abc | a followed by b followed by c
[abc] | A single character, one of a or b or c
[a-b] | A single character, ranging in value from a to b inclusive
[^abc] | A single character, any except a, b or c
(abc) | a followed by b followed by c
"abc" | The letters a followed by b followed by c with no special significance attached to a, b or c
. | Any character except a new line
\t | The tab character
\n | The newline character
\r | The return character

In order to search for literal instances of characters that would otherwise denote RE operators, you must escape them by preceding them with a \ . For example, to find a plus (+) sign, use \+

Regular expression examples:

[0-9]+pt | Match all "pt" units
#[0-9]+ | Match all hexadecimal colors
\/\*[^*]*\*+([^/][^*]*\*+)*\/ | Match all CSS comments
[Uu][Rr][Ll]\([^\)]*\) | Match all URL values
\{[^\}\{]*\} | Match all declaration blocks

Note that regular expressions are powerful -- and dangerous. You should always run a search on your REs to make sure you are matching the strings that you want before running a RE replace.

Related topics: Find, Replace

Section Contents | Help Contents