Find and Replace with Regular

Expressions

Characters have special meaning during search and replace operations.

UNIX regular expressions - When regular expressions are turned on for a search and replace com- mand, the backslash character (\) has special meaning in the replace string. A backslash in the replace string has the same meaning as in the search string except that \c and \:char are not supported. See UNIX Regular Expressions for a list of backslash (\) options. See Using Tagged Search Expressions for information on specifying tagged expressions in the replace string.

SlickEdit® regular expressions - When regular expressions are turned on for a search and replace command, the number sign character (#) and backslash (\) have special meaning in the replace string. A backslash in the replace string has the same meaning as in the search string except that \c, :char, and \gd are not supported. See SlickEdit Regular Expressions for a list of backslash (\) options. See Using Tagged Search Expressions for information on specifying tagged expressions in the replace string using the number sign (#) character.

Brief regular expressions - When regular expressions are turned on for a search and replace com- mand, the backslash character (\) has special meaning in that backslash in the replace string has the same meaning as in the search string except that \c and \:char are not supported. See Brief Regular Expressions for a list of backslash (\) options. See Using Tagged Search Expressions for information on specifying tagged expressions in the replace string.

The following table contains some examples of replace operations using regular expressions:

Table 6.13. Examples of Replacing Using Regular Expressions

Example

Description

 

 

Search For: hat$

Search for occurrences of the string "hat" that occur

Replace With: cat

at the end of a line and replace it with "cat".

UNIX and SlickEdit® regular expression:

Delete blank lines.

Search For: ^\n

 

Replace With:

 

Brief regular expression:

 

Search For: <\n

 

Replace With:

 

 

 

UNIX and SlickEdit regular expression:

Replace occurrences of two consecutive blank lines

Search For: ^\n\n

with one.

Replace With: \n

 

Brief regular expression:

 

Search For: <\n\n

 

Replace With: \n

 

UNIX regular expression:

Search for lines containing "a" and replace the "a"

Search for: ^a+$

with a formfeed character.

193

Page 215
Image 215
Slick V3.3 Find and Replace with Regular Expressions, Unix and SlickEdit regular expression, Brief regular expression