Need help with a find and replace expression - tks -

General discussions about Advanced Find and Replace
Post Reply
travch
Posts: 2
Joined: Sun Feb 06, 2005 8:24 pm

Need help with a find and replace expression - tks -

Post by travch »

I am just trying out Advanced find and replace and it looks great.

Unfortunately I am a total newbie with regular or normal expressions and am going nuts about trying to replace some spaces into +. Sometimes it can be that there is no space if there is only on keyword within the value.

Hope someone can help me :)

I have following line in various html files:

<!--#set var="keyword" value="keyword1 keyword2 keyword3" -->


the keyword1 etc is allways a different word. It can be only one keyword or up to 6 keywords i.e. keyword1 keyword2 keyword3 keyword4 etc.

What I need to do is to keep the words the same whatever they are but replce the spaces inside the value variable into a +

The result should be like

<!--#set var="keyword" value="keyword1+keyword2+keyword3" -->

so one result example could be:

<!--#set var="keyword" value="hello+world+me" -->

an other

<!--#set var="keyword" value="hello" -->

or

<!--#set var="keyword" value="hello+today+is+my+birthday" -->

Hope I was able to explain in enough detail.

Any help is very appreciated.

Thanks

Trav

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Hi,

There can be a plenty different variants.
For example one of them:

Go to Batch replace, enable "Use regular expressions".
Put into search for:
"keyword"(\s*)value="(\S*) (.*)"

Replace with:
"keyword"$1value="$2+$3"

Then press Execute button 5 times (as far as you have up to 6
keywords).

I verified it works fine.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

travch
Posts: 2
Joined: Sun Feb 06, 2005 8:24 pm

Post by travch »

That worked like a charm :)

Thanks very much Roman.

Post Reply