Wildcard F/R

General discussions about Advanced Find and Replace
Post Reply
MrG
Posts: 4
Joined: Tue Mar 13, 2007 7:13 pm

Wildcard F/R

Post by MrG » Tue Mar 13, 2007 7:42 pm

I've checked through the other posts, and I think I understand how to do a variable find and replace, but I'm missing the obvious it seems...

I have a few html files that have code like this in it...
<IMG src="thumbnails/th_My%20Photo.jpg"

I need to replace it with:
<IMG src="../vwimages/th_My%20Photo.jpg/$FILE/th_My%20Photo.jpg"

So should I be doing a simple find and replace or a batch?

I think this is how it should be done...
search:
<IMG src="thumbnails/th_(.*).jpg"

replace:
<IMG src="../vwimages/$1/$FILE/$1.jpg"


Does this make sense at all?

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

Post by Abacre » Tue Mar 13, 2007 7:58 pm

In this version of Advanced Find and Replace you can use regular
expressions on Batch Replace tab.

The right regular expressions pair is:

Search for:
<IMG src="thumbnails/(th_.*)\.jpg"

Replace with:
<IMG src="../vwimages/$1/$FILE/$1.jpg"

. - dot before jpg is reserved char in search for (but not in replace
with!). So you have to escape it with \

Then in your example you have to put ( before th_

I verified it worked as expected.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

MrG
Posts: 4
Joined: Tue Mar 13, 2007 7:13 pm

Post by MrG » Wed Mar 14, 2007 3:20 pm

I see... so I should be putting this in the expression builder dialog box.. and not manually... correct?

BTW: It did work...

Mucho thanks..

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

Post by Abacre » Wed Mar 14, 2007 4:31 pm

For testing you should put it into Regular Expressions Builder.
Otherwise (for real replace) you should put it into Batch Replace
grid.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

MrG
Posts: 4
Joined: Tue Mar 13, 2007 7:13 pm

Post by MrG » Fri Mar 16, 2007 8:38 pm

Still doing some work on this... and for some reason the batch replace grid does not seem to like the '$FILE' piece... is the $ a reserved character?

I notice that it seems to duplicate a large part of the text of the document. e.g. I have a 5x5 table... after the replace, I have a 5 x 10 table.

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

Post by Abacre » Fri Mar 16, 2007 8:54 pm

Exactly. $ is a reserved char.

So in Search For part you should put \ before $ like this:
\$

But in Replace With part you can use $ without \

For example you can use $FILE in Replace With part but you should use
\$FILE in Search For part.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

MrG
Posts: 4
Joined: Tue Mar 13, 2007 7:13 pm

Post by MrG » Mon Mar 19, 2007 1:44 pm

Now what happens in the scenario where there is no "$FILE" in the search part, but is being added in the replace?

e.g. if I am searching for:
vwimages/(.*)\.jpg

and replacing with:
vwimages/th_$1.jpg/$FILE/$1.jpg"

The original string does not contain "$FILE" but is being inserted...

Even after some further testing, I guessing that "$FILE" is another reserved word... I think this copies the whole file and pastes it back in.. which might explain why my tables are being super-sized!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests