Page 1 of 1

How to search and replace a variable chain

Posted: Thu Jan 20, 2011 10:30 pm
by Patick
Hi,

I would like to search and delete, in hundreds of html files, the following chain :
width=xxx

Each x is a digit that can be 0 or 1 or 2 or 3, ....or 9.
Is there a way to do this work with TextCrawler ?
I thank you in advance for any help.

Kind Regards,
Patrick

Posted: Thu Jan 20, 2011 11:10 pm
by Fool4UAnyway
It's really not that hard.

If you know some regular expression basics, you can directly translate your request into the following regular expression:

width=\d{3}

Perhaps you will want to remove any addition characters like a separator, a comma, for example, possibly followed by a space character, maybe optionally: (, )?

width=\d{3}(, )?

Perhaps you want to delete the complete lines if they only contain these width specifications:

width=\d{3}\r\n

or

\r\nwidth=\d{3}

Just take a look here:

http://www.regular-expressions.info


Posted: Fri Jan 21, 2011 11:07 am
by Patrick
Hi,

I thank you very much for your prompt and very useful reply.

I had a look at the link you sent me.

But, until now, I was not able to find the way to do another work with TextCrawler :
- replacing any color code without double qoutes, with the same color code having the double quote.
In another words, I would like to replace in all my html files, every chain like =#0f488d by ="#0f488d"
Thai is to say that I would like to add the w3c required double quotes to all my color codes

Once again, thank you in advance to let me knwo if such replacement is possible with textCrawler.

Kind Regards,
Patrick



Posted: Fri Jan 21, 2011 12:52 pm
by Old Gregg
Find:
=#(\w{6})

Replace:
="#$1"

This will do the 6-character codes (you might need to vary the {6} part. Try it in the tester.


Posted: Fri Jan 21, 2011 5:14 pm
by Patrick
Thank you again for this prompt and useful reply.

Kind Regards,
Patrick