-
-
Notifications
You must be signed in to change notification settings - Fork 1
Find Replace Transmogrification
Do you ever find yourself with the editing situation where you need to transform a text pattern to a string that contains information in that pattern? For example, suppose you want to convert all Tcl style assignments to C-style assignments.
Tcl:
set foo “some value”
C:
foo = “some value”;
This may seem like a time-consuming task until you know that TKE supports this type editing with the Find / Find and Replace capability. Because “Find and Replace” supports regular expression syntax, you can place any text that you would like to use in the “Replace” field by surrounding them with parenthesis in the “Find” field. You can then reference these matched text values in the “Replace” field by specifying a backslash () character followed by a number with corresponds to the left parenthesis order (starting at a value of 1).
So to implement a solution to the problem above, we could search the text for the pattern:
(s+)sets+(w+)s+(.*)$
This will place the preceding whitespace into variable “1”, the variable name of the Tcl “set” command into variable “2” and the value being assigned to the variable in variable “3”. We can then perform the text transformation in the replace entry field with the value:
12 = 3;
Once the text has been input, all Tcl set commands found in the editing buffer will be transformed into the C equivalents.
Pretty slick right? Use this powerful editing feature to make quick work of complex, repetitive editing tasks.