Help with regex find/replace in Dreamweaver

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
m2244
Forum Newbie
Posts: 2
Joined: Tue Mar 20, 2012 9:14 am

Help with regex find/replace in Dreamweaver

Post by m2244 »

Hello,

I need help with a regex find and replace. I want to replace this string

'showPopUp(url, title, width, height)'

with this string

'showHidePup(url, title)'

The name of the function changes and the width height attributes are no longer needed. I have the regex that finds the first string

Code: Select all

showPopUp\(.+\)
But how can I replace it with a new function name and remove those last 2 attributes without changing the 'url' and 'title' attributes?
User avatar
ragax
Forum Commoner
Posts: 85
Joined: Thu Dec 15, 2011 1:40 pm
Location: Nelson, NZ

Re: Help with regex find/replace in Dreamweaver

Post by ragax »

HI m2244,

Welcome to the forum.

Try this. I just tested in DW 5.5, it worked with my test strings.
Search:

Code: Select all

showPopUp\(([^,]+,[^,]+)[^)]+\)
Replace:

Code: Select all

showHidePup($1)
Note that with this particular phrasing, the regex will run into trouble if the title contains commas.
Let us know how this work and if you need more help. :)
Post Reply