PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Jul 19, 2019 10:39 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Mar 20, 2012 9:31 am 
Offline
Forum Newbie

Joined: Tue Mar 20, 2012 9:14 am
Posts: 2
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

Syntax: [ Download ] [ Hide ]
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?


Top
 Profile  
 
PostPosted: Tue Mar 20, 2012 2:35 pm 
Offline
Forum Commoner
User avatar

Joined: Thu Dec 15, 2011 2:40 pm
Posts: 85
Location: Nelson, NZ
HI m2244,

Welcome to the forum.

Try this. I just tested in DW 5.5, it worked with my test strings.
Search:
Syntax: [ Download ] [ Hide ]
showPopUp\(([^,]+,[^,]+)[^)]+\)

Replace:
Syntax: [ Download ] [ Hide ]
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. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group