Find words also with a string in it

Find, replace, find in files, replace in files, regular expressions

Find words also with a string in it

Postby phantom » Sun May 08, 2011 6:18 am

Hi,

my english isn't so good. So it's really hard for me to search in this forum for my problem.

I want to search for words which could also have some strings.
Example: find highlight, but also h&lnkighlight, high&lnklight

Next step, search this differents expressions and replace these with a new one.
Example: find highlight, but also h&lnkighlight, high&lnklight
replace highlight with Highway, and replace also h&lnkighlight, high&lnklight with Highway

I hope you understand my simple problem and somebody can help me.
I wish ultraedit would have more examples in the online help.

Best regards,

phantom
phantom
Newbie
 
Posts: 2
Joined: Sun May 08, 2011 5:48 am

Re: Find words also with a string in it

Postby Mofi » Sun May 08, 2011 9:29 am

Normally a regular expression search can be used for finding strings with various content. But in your case there is a big problem because &lnk can exist anywhere inside the word highlight and that makes it impossible to find all variations with a simple regular expression expression.

The best idea I have is to use the Perl regular expression engine and enter all possible variations in a big OR expression. So the search string would be

highlight|&lnkhighlight|h&lnkighlight|hi&lnkghlight|hig&lnkhlight|high&lnklight|highl&lnkight|highli&lnkght|highlig&lnkht|highligh&lnkt|highlight&lnk

It is possible to search with Perl regular expression engine for [&ghiklnt]{9,13}\> which means:

Find a string with any character in the square brackets, ending at end of a word, with a minimum length of 9 and a maximum length of 13 characters.

If there is surely no occurrence of &lnkhighlight, the search string could be changed to \<h[&ghiklnt]{8,12}\> to further restrict the search to find only words starting with letter H.

But both of these general search strings can nevertheless also find other words with correct length and consisting only of the letters in the square brackets.

To reduce the number of found strings to 9 or 13 characters, the Perl regular expression search string [&ghiklnt]{13}\>|\<highlight\> could be used, but false found strings are nevertheless possible.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Find words also with a string in it

Postby phantom » Sun May 08, 2011 10:11 am

Thanks for your effort. I hoped that it would be possible to exlude or ignore a character or a string in a search request.
phantom
Newbie
 
Posts: 2
Joined: Sun May 08, 2011 5:48 am

Re: Find words also with a string in it

Postby pietzcker » Tue May 10, 2011 1:25 am

Another option would be to search for

Code: Select all
h(?:&lnk)?i(?:&lnk)?g(?:&lnk)?h(?:&lnk)?l(?:&lnk)?i(?:&lnk)?g(?:&lnk)?h(?:&lnk)?t
User avatar
pietzcker
Master
Master
 
Posts: 242
Joined: Sun Aug 22, 2004 11:00 pm


Return to Find/Replace/Regular Expressions