Regular Expressions - Literals

image\regex2_shg.gif

The following characters have special meaning when regular expression mode is enabled. If you wish to use a 'literal' of one these special characters, precede it with the \ character.

Expression Type

Special Characters

Search Expressions

+ * ? ( ) [ ] \ | $ ^ !

Replacement Expressions

% \ < >

Building Scripts (see note below)

In addition to the above, [ and ]

Examples:

Goal: Find (1.1MB), (340K), (self-install)

Search Term: \(*\)

Explanation: The ( and ) characters are normally related to the () paren search sub-expression operator. If you don't preface the ( and ) characters here with \, the program would interpret the search as one involving () paren and you might not get the results you want.

Goal: Page references in html code that begin with the letter D and change them to lower case.

Search term: .htm*">D*</a>

Replace Term: .htm%1"d%2<\</a>

Explanation: The < and > characters in a replacement expression are characters used by the counter and case change operators when they are immediately adjacent to a %n operator. Because the literal < character in the ending </a> tag is adjacent to %2, the program would not know if how to interpret <. Therefore make it a literal.

Special Note about Scripts:

If you are using search/replace(s) in a script that creates or modifies another script, special care should be taken with the [ and ] characters. Search and Replace scripts contain several special 'section tags' that are bounded by [ and ]. For example, a script can contain an [Options] section (see Format of Script files for a complete sample). You should preface [ and ] with the \ character to avoid confusing the script parser. For example, say you have Script1.srs that transforms a given file into a working script by creating [Search] and [Replace] sections. You should preface the [ and ] characters with \ to avoid confusing script parser as it reads Script1.srs.

Other Regular Expression Hlp Topics

Search Operators

Replacement Operators

Examples