Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

Advanced Find and Replace

TheIDE find and replace in the block, using wildcards, has some specific features available that make it suitable for some lightweight text transformations.

 

(Note: TheIDE also supports normal regular expressions in addition to wildcards.)

 

Now first thing to mention is that you can search and replace for line ending character using \n and for tabulator using \t (use \\n and \\t for escaping). So to put several lines into single line, use

 

search:    \n

replace:    (nothing)

 

Or to replace ',' with tabulator, use

 

search:    ,

replace:    \t

 

When search&replace is case-insensitive, it is often useful when replace follows the case of source. This option is activated by "Mimic case" switch. Consider

 

Foo

FOO

foo

FoO

 

 

Bar

BAR

bar

Bar

 

Note that in the last line, the last letter is not uppercased - replaced text can have different length, so the result of operation is determined by checking the first two characters only, resulting in lower-case, upper-case or init-caps scenarios.

 

For more interesting things to happen, you can activate wildcards:

 

 

Wildcards allow matching numbers, identifiers, spaces or any text. You can get help about wildcards and insert wildcards by clicking small arrow in the right part of Find field:

 

 

Note that pattern matching is done on per-line basis ('One or more any characters' do not include line-ending). When pattern is matched, it is possible to use matched wildcards in replace text. Again, you can get the list of replacement placeholders by clicking small arrow in the right part of Find field:

 

 

Now for some practical examples. Suppose you want to 'extract' only identifiers inside THISBACK(). You can do that using

 

out.Escape("EditFile(...)", THISBACK(MacroEditFile));

out.Escape("SaveCurrentFile()", THISBACK(MacroSaveCurrentFile));

out.Escape("CloseFile()",THISBACK(MacroCloseFile));

 

search:    *THISBACK($)*\n

replace:    $\n

 

MacroEditFile

MacroSaveCurrentFile

MacroCloseFile

 

You can use positional replace wildcards to change the order of identifiers, e.g.

 

out.Escape("EditFile(...)", THISBACK(MacroEditFile));

out.Escape("SaveCurrentFile()", THISBACK(MacroSaveCurrentFile));

out.Escape("CloseFile()",THISBACK(MacroCloseFile));

 

search:    *"$*THISBACK($)*\n

replace:    *"@4*THISBACK(@2)*\n

 

out.Escape("MacroEditFile(...)", THISBACK(EditFile));

out.Escape("MacroSaveCurrentFile()", THISBACK(SaveCurrentFile));

out.Escape("MacroCloseFile()",THISBACK(CloseFile));

 

In replace wildcard, it is also possible to specify that the text is converted to upper-case, lower-case or init-caps (first letter upper-case, rest lowercase):

 

out.Escape("EditFile(...)", THISBACK(MacroEditFile));

out.Escape("SaveCurrentFile()", THISBACK(MacroSaveCurrentFile));

out.Escape("CloseFile()",THISBACK(MacroCloseFile));

 

search:    THISBACK($)

replace:    THISBACK($+)

 

out.Escape("EditFile(...)", THISBACK(MACROEDITFILE));

out.Escape("SaveCurrentFile()", THISBACK(MACROSAVECURRENTFILE));

out.Escape("CloseFile()",THISBACK(MACROCLOSEFILE));

 

Finally, it it also possible to insert the replace index (either 0 or 1 based) into replace text (here combined with init-caps):

 

out.Escape("EditFile(...)", THISBACK(MacroEditFile));

out.Escape("SaveCurrentFile()", THISBACK(MacroSaveCurrentFile));

out.Escape("CloseFile()",THISBACK(MacroCloseFile));

 

search:    THISBACK($)

replace:    THISBACK($!@#)

 

out.Escape("EditFile(...)", THISBACK(Macroeditfile1));

out.Escape("SaveCurrentFile()", THISBACK(Macrosavecurrentfile2));

out.Escape("CloseFile()",THISBACK(Macroclosefile3));

 

 

Last edit by cxl on 07/13/2015. Do you want to contribute?. T++