Example 7
Return to Introduction  Previous page  Next page
Description: You have numerous DEFINEs that refer to your product name. E.g.:

DEFINE REGKEY_SETTINGS := "My Cool App\Settings"
DEFINE REGKEY_DEFAULTS := "My Cool App\Defaults"

etc.

Suppose you decide you want to put the application name in its own DEFINE and have all the existing DEFINEs refer to it. E.g.:

DEFINE MYAPP := "My Cool App"
DEFINE REGKEY_SETTINGS := MYAPP + "\Settings"
DEFINE REGKEY_DEFAULTS := MYAPP + "\Defaults"


Manually creating the new MYAPP DEFINE is easy. How can you use regular expressions to change all the existing DEFINEs that contain your application name?


Search expression: ^DEFINE(.*)"My Cool App\\(.*)

Explanation:
^DEFINE
Match the characters DEFINE at the start of line
(.*)
Any characters
"My Cool App
The application name
\\
The \ character
(.*)
Any characters


Replace expression: DEFINE#0MYAPP + "\#1

Explanation:
DEFINE
The characters DEFINE
#0
The characters that matched the first (.*)
e.g. REGKEY_SETTINGS :=
MYAPP   
The characters of the name of your new DEFINE
+ "\
Plain text that goes straight into the new string
#1
The characters that matched the second (.*)
e.g. Settings"

            


© Piko Computing Consultants, 1998-2002