How to make a regex for Dreamwaver find and replace?

I have the following code in about 300 HTML files, I need to replace it with some other code. But the problem is in the following code: ID click=12FA863

changes and is different in every file, I want to use regex that will work in Find and replace in Dreamwaver.

<iframe src="http://example.net/?click=12FA863" width=1 height=1 style="visibility:hidden;position:absolute"></iframe>

      

thanks

0


a source to share


4 answers


Placed

<iframe src="http://example\.net/\?click=[^"]+" width=1 height=1 style="visibility:hidden;position:absolute"></iframe>

      



in the search box and whatever you want to replace in the replace box and you should be set.

+3


a source


Here is a tutorial on Dreamweaver Regex.



http://www.adobe.com/devnet/dreamweaver/articles/regular_expressions_pt1.html

+2


a source


If, as you said in your comment, you want to replace

<iframe src [Anything] </iframe>

      

Then this will do:

<iframe src.+</iframe>

      

Where "." means "any character" and "+" means "1 or more of them"

If you are curious about the click id value or any other part, you want to capture it, for example:

<iframe src.+click=([A-F0-9]+).+</iframe>

      

and when replacing, use $ 1 (or $ 2, $ 3, etc. if you add more).

Note that [A-F0-9] + simply means "one or more hexadecimal characters"

So if you used this regex, and this is as a replacement:

<div>something else using $1</div>

      

Then

<iframe src="http://example.net/?click=12FA863" width=1 height=1 style="visibility:hidden;position:absolute"></iframe>

      

Would become

<div>something else using 12FA863</div>

      

I would definitely spend some time with Daniel's recommended tutorial and also look at other Regex tutorials, cheat sheets, etc. such as visibone.com/regular-expressions

+1


a source


<iframe.+?</iframe>

      

This is a lazy regex that looks for a finisher tag </iframe>

.

This regex doesn't care where it is src

, it will find it too <iframe width... src=.. ></iframe>

.

+1


a source







All Articles