s_hausen
asked on
Regex Find and Replace
Hi,
I am looking for some regex FIND AND REPLACE solutions, as I've forms who has 100's of checkboxes and radio buttons. I am using Dreamweaver...
In first problem, i need a regex which only targets the name attributes of the inputs and add the code at the end of the input tags.
For eg: i've input 3 input checkboxes/radio tags and you see the attributes are not in same format and order.
In second problem, regex again targets the name attribute of input tags of checkboxes/radio buttons and format the tags.
for eg: i've 2 input tags.
In third problem, regex targets the SECTION of <cfif IsDefined("FORM.OrientTime ") AND FORM.OrientTime EQ '1'>checked="checked" </cfif> and replace'em.
for eg: I've 3 input tags.
Thanks in advace..
I am looking for some regex FIND AND REPLACE solutions, as I've forms who has 100's of checkboxes and radio buttons. I am using Dreamweaver...
In first problem, i need a regex which only targets the name attributes of the inputs and add the code at the end of the input tags.
For eg: i've input 3 input checkboxes/radio tags and you see the attributes are not in same format and order.
<input name="Oriented" type="checkbox" id="Oriented" value="1" style="height:11px" />
<input name="Time" type="checkbox" id="Time" value="1" onClick="abc();" />
<input type="radio" name="OrientTime" id="OrientTimeA" tabindex="340" />
[b]LOOKS LIKE THAT AFTER REGEX FIND AND REPLACE[/b]
<input name="Oriented" type="checkbox" id="Oriented" value="1" style="height:11px" <cfif IsDefined("FORM.Oriented") AND FORM.Oriented EQ '1'>checked="checked" </cfif>/>
<input name="Time" type="checkbox" id="Time" value="1" onClick="abc();" <cfif IsDefined("FORM.Time") AND FORM.Time EQ '1'>checked="checked" </cfif>/>
<input type="radio" name="OrientTime" id="OrientTimeA" tabindex="340" <cfif IsDefined("FORM.OrientTime") AND FORM.OrientTime EQ '1'>checked="checked" </cfif>/>
In second problem, regex again targets the name attribute of input tags of checkboxes/radio buttons and format the tags.
for eg: i've 2 input tags.
<cfinput type="checkbox" name="Sputum" id="Sputum" tabindex="120" value="1">
<cfinput type="checkbox" name="vital" id="vital" value="1" required="yes" style="padding:4px;">
[b]LOOKS LIKE THAT AFTER REGEX FIND AND REPLACE[/b]
<cfif #Sputum# EQ 1>
<cfinput type="checkbox" name="Sputum" id="Sputum" tabindex="120" value="1" checked="yes">
<cfelse>
<cfinput type="checkbox" name="Sputum" id="Sputum" tabindex="120" value="1" checked="no">
</cfif>
<cfif #vital# EQ 1>
<cfinput type="checkbox" name="vital" id="vital" value="1" required="yes" style="padding:4px;" checked="yes">
<cfelse>
<cfinput type="checkbox" name="vital" id="vital" value="1" required="yes" style="padding:4px;" checked="no">
</cfif>
In third problem, regex targets the SECTION of <cfif IsDefined("FORM.OrientTime
for eg: I've 3 input tags.
<input name="Oriented" type="checkbox" id="Oriented" value="1" style="height:11px" <cfif IsDefined("FORM.Oriented") AND FORM.Oriented EQ '1'>checked="checked" </cfif>/>
<input name="Time" type="checkbox" id="Time" value="1" onClick="abc();" <cfif IsDefined("FORM.Time") AND FORM.Time EQ '1'>checked="checked" </cfif>/>
<input type="radio" name="OrientTime" id="OrientTimeA" tabindex="340" <cfif IsDefined("FORM.OrientTime") AND FORM.OrientTime EQ '1'>checked="checked" </cfif>/>
[b]LOOKS LIKE THAT AFTER REGEX FIND AND REPLACE[/b]
<input name="Oriented" type="checkbox" id="Oriented" value="1" style="height:11px" <cfif #Oriented# EQ '1'>checked="checked" </cfif>/>
<input name="Time" type="checkbox" id="Time" value="1" onClick="abc();" <cfif #Time# EQ '1'>checked="checked" </cfif>/>
<input type="radio" name="OrientTime" id="OrientTimeA" tabindex="340" <cfif #OrientTime# EQ '1'>checked="checked" </cfif>/>
Thanks in advace..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi kaufmed,
all the regex's are working like charm. you really are a life saver. thanks a bunch, deeply appreciated.
all the regex's are working like charm. you really are a life saver. thanks a bunch, deeply appreciated.
NP. Glad to help = )
If the dollar symbols don't work in the replacement expressions, try using backslashes instead.
e.g.
Open in new window