Regular Expression Search – Match Operators | ||||||||||||||||||||||||||
Operator | Description | |||||||||||||||||||||||||
* |
|
|||||||||||||||||||||||||
+ |
|
|||||||||||||||||||||||||
? |
|
|||||||||||||||||||||||||
! |
In this example:
These parameters can be used several times, omitted or used in any order. |
|||||||||||||||||||||||||
will replace the original first matched expression with its upper case version. | ||||||||||||||||||||||||||
%n> | Counter Operator. When used in conjunction with numeric regular expression search (e.g., *[0-9]), %n> begins incrementing with a value of +1 from the value of the first number found by *[0-9]. For example:
|
|||||||||||||||||||||||||
%n>#> | Counter Operator. This operator allows you to specify a starting value for an incrementing replacement counter. %n>starting value> begins incrementing with a value of +1 from the starting value you supply. This counter operator also respects the number of digit places you supply. To begin incrementing with a value of 1, use the expression %n>0>. The expression %n>000> would begin replacements with a a value of 001. Another example is:
|
Top | Search & Replace Features | Search & Replace Page
Top | Search & Replace Features | Search & Replace Page
Regular Expression Search & Replacement Examples | ||
Search Expression |
Replacement Expression |
Effect |
*.* | %1>.%2> | c:\windows\win.ini ==> C:\WINDOWS\WIN.INI |
+[a-z] | %1> | Windows ==> WINDOWS |
7*.htm | 5%1.htm | 711.htm ==> 511.htm 7days.htm ==> 5days.htm |
[253]7[832].htm | %15%2.htm | 3572.htm ==> 3552.htm |
*[253]7[832].htm | %15%2.htm | 72.htm ==> 52.htm |
(homepage|index).htm | %11.htm | homepage.htm ==> homepage1.htm index.htm ==> index1.htm |
+(12)[0-9] | %1%2a | 12532 ==> 12532a 1212753 ==> 1212753a |
???*(d|m).htm | %1%2%3d1.htm | card.htm ==> card1.htm form.htm ==> form1.htm |
back2.jpg*[]height=”30″ | back2.jpg%1height=”32″ | A multiline Search/Replace changing the height setting for ‘back2.jpg’ regardless of differing ‘alt’ text or how the html editor line breaks the code, e.g., src=”images/back2.jpg” alt=”Go Back” border=”0″ width=”57″
height=”30“ Becomes: src=”images/back2.jpg” alt=”Go Back” border=”0″ width=”57″ height=”32“ |
?(Windows) | OS/2 | Windows ==> OS/2 (just kidding) |
Top | Search & Replace Features | Search & Replace Page
Regular Expression Counters |
|||||||||||||||||||||||||||||||||||||||||
Regular Expression search & replace Counter Operations allow you to quickly revise a sequence of numbers in one or more files. You can also insert sequential numbers to text strings where no numbers exist originally. Counter operations make use of *[0-9] regular expression search operator and either the %n> or %n>user defined starting value> regular expression replacement operators.
The %n> replacement operator begins incrementing by one with a value of +1 from the value found by your *[0-9] expression (e.g.*[0-9]+1). The %n>user defined starting value> replacement operator increments by one beginning with a value of (user defined starting value+1). This counter operator also respects the number of digit places you supply. Incrementing counter operations may be combined with other regular expression search & replace operators. For example, a search expression such as (file|variable)*[0-9] with a counter replacement expression such as %1%2>100> is perfectly legal.
|
Top | Search & Replace Features | Search & Replace Page
Special Replacement Operators – %%srpath%% & %%srfile%% |
|||||||||||||||||||||||||||||||||||||
Search and Replace currently has two special replacement operators – %%srpath%% and %%srfile%%. %%srpath%% inserts the path to the file in which the search string was found and %%srfile%% inserts the filename of that file. %%srpath%% and %%srfile%% can be used in ordinary search & replace operations, Regular Expression operations, Regular Expression counters, & Binary mode operations.
|
Top | Search & Replace Page
Environment Operators |
You can search for, or make replacements based on, Environment Variables via the Binary Mode dialog or a Regular Expression string. Searches may be case sensitive or not. The syntax is: %%envvar=variable name%%
where variable name is the name of the environment variable to use. For example, to search for the environment variable temp, enter the string %%envvar=temp%% in the binary mode search block field or your regular expression. If the value of your temp environment variable is c:\windows\temp, search hits would occur wherever the string c:\windows\temp is found. If Case Sensitive is on, c:\windows\temp would be found but C:\WINDOWS\TEMP would not. To insert the value of the environment variable winbootdir in a replacement string, enter the string %%envvar=winbootdir%% in binary mode replace block field or your regular expression. If the value of your winbootdir variable is C:\WINDOWS, the string C:\WINDOWS would be used in replacements. |
Courtesy Funduc Software ©2000 Funduc Software. All rights reserved.