How to search and replace a variable chain

Tool for Search and Replace across multiple files.
User avatar
Patick

How to search and replace a variable chain

Post 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
User avatar
Fool4UAnyway

Post 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

User avatar
Patrick

Post 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


User avatar
Old Gregg

Post 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.

User avatar
Patrick

Post by Patrick »

Thank you again for this prompt and useful reply.

Kind Regards,
Patrick

Post Reply