Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 13th, 2010, 01:15 PM
ihussain ihussain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 30 ihussain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 54 m 25 sec
Reputation Power: 4
Find & Replace

Hi,
I've more than 558 fields to update with diffrent names & id's.
for eg:

Code:
<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexSR" id="ShoulderFlexSR" tabindex="20" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexRML" id="ShoulderFlexRML" tabindex="30" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexRMR" id="ShoulderFlexRMR" tabindex="40" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" >


I am wondering is there a way I can use FIND & REPLACE -offcourse with some regex to accomplish this task & add another value attribute in those inputs with same name & id attributes value.

<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" value="#ShoulderFlexSL#">
<cfinput type="text" name="ShoulderFlexSR" id="ShoulderFlexSR" tabindex="20" size="8" maxlength="50" value="#ShoulderFlexSR#">
<cfinput type="text" name="ShoulderFlexRML" id="ShoulderFlexRML" tabindex="30" size="8" maxlength="50" value="#ShoulderFlexRML#">
<cfinput type="text" name="ShoulderFlexRMR" id="ShoulderFlexRMR" tabindex="40" size="8" maxlength="50" value="#ShoulderFlexRMR#">

Any comments would be deeply appreciated.

Reply With Quote
  #2  
Old January 13th, 2010, 11:56 PM
shivercube shivercube is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2010
Location: Brisbane, Australia
Posts: 20 shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level)shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level)shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level)shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level)shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level)shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level)shivercube User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 8 h 16 m 33 sec
Reputation Power: 0
Send a message via MSN to shivercube
Well you could use a regular expression such as:
Code:
Find: (<cfinput.+?name="([a-z]+)".+?id="\2".+?)(?=>)
Replace: $1value="#$2#">


You could either create a small script, or do it in an advanced text editor. Since I currently have my PHP IDE open, I did it in PHP as an example.

PHP Code:
 $string '<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexSR" id="ShoulderFlexSR" tabindex="20" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexRML" id="ShoulderFlexRML" tabindex="30" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexRMR" id="ShoulderFlexRMR" tabindex="40" size="8" maxlength="50" >
<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" >'
;

echo 
'<pre>',
    
htmlentities(preg_replace('/(<cfinput.+?name="([a-z]+)".+?id="\2".+?)(?=>)/i''$1value="#$2#"'$string)),
    
'</pre>'


Produces:
Code:
<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" value="#ShoulderFlexSL#">
<cfinput type="text" name="ShoulderFlexSR" id="ShoulderFlexSR" tabindex="20" size="8" maxlength="50" value="#ShoulderFlexSR#">
<cfinput type="text" name="ShoulderFlexRML" id="ShoulderFlexRML" tabindex="30" size="8" maxlength="50" value="#ShoulderFlexRML#">
<cfinput type="text" name="ShoulderFlexRMR" id="ShoulderFlexRMR" tabindex="40" size="8" maxlength="50" value="#ShoulderFlexRMR#">
<cfinput type="text" name="ShoulderFlexSL" id="ShoulderFlexSL" tabindex="10" size="8" maxlength="50" value="#ShoulderFlexSL#">

Reply With Quote
  #3  
Old January 14th, 2010, 08:22 AM
ihussain ihussain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 30 ihussain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 54 m 25 sec
Reputation Power: 4
shivercube,
you are one smart fellow I do appreciate your help & again can't thx ya enough for that..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Find & Replace

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap