Link to home
Start Free TrialLog in
Avatar of ambantin
ambantin

asked on

Simple code needed for Dreamweaver Regular Expression

I have several pages where I am using php and I need to find and replace

"$comp",$num+1,".php"

with

"$comp"

However, the +1 in the original is +1 to +32 in the pages

I need someone to reply with the code I need to do this..
ASKER CERTIFIED SOLUTION
Avatar of Gary Davis
Gary Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ambantin
ambantin

ASKER

didn't work...
here is another example

"$comp",$num+1,".php"
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
still not working... ugh
Is this for the Find/Replace dialog, or for ReReplace function?
Find Replace - Dreamweaver MX
I think I told you a white lie...  because I misread your original example. In gardavis' example, leave the quotes, but try replacing the "\d{1,2}" with a literal "1".

i.e.
"\$comp",\$num\+1,"\.php"

Open in new window

To account for the "+32", try using:

"\$comp",\$num\+[0-9]+,"\.php"

Open in new window

still not found in current document....
here is a sample of the code I am using

it is the comp line that needs to be changed in every page... 76 entries
</tr>
  <tr> 
    <td height="134" align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="middle"> <h2><a href="<?php echo "$socstud",$num,".php"; ?>">Social 
        Stud</a><br />
        <a href="<?php echo "$whist",$num,".php"; ?>">World 
        Hist</a><br />
        <a href="<?php echo "$lgsocstud",$num,".php"; ?>"><font color="#00FF00">Social 
        Stud</font></a><br />
        <a href="<?php echo "$comp",$num,".php"; ?>">Computer</a><br />
        <a href="<?php echo "$math",$num,".php"; ?>">Math</a><br />
        <a href="<?php echo "$science",$num,".php"; ?>">Science</a><br />
      </h2></td>
    <td align="center" valign="middle"> <h2><a href="<?php echo "$rel",$num+1,".php"; ?>">Religion</a><br />
        <a href="<?php echo "$lgsocstud",$num+1,".php"; ?>"><font color="#00FF00">Social 
        Stud</font></a><br />
        <a href="<?php echo "$comp",$num+1,".php"; ?>">Computer</a><br />
        <a href="<?php echo "$biology",$num+1,".php"; ?>">Biology</a><br />
        <a href="<?php echo "$science",$num+1,".php"; ?>">Science</a><br />
        <a href="<?php echo "$health",$num+1,".php"; ?>">Health</a><br />
      </h2></td>

Open in new window

Silly question (which assumes I'm looking at an applicable version in the screenshot I reviewed):  Do you have the "Use Regular Expressions" box checked?
yes i do
Has anyone got it to work?
Does DreamWeaver regular expressions work the same as others? My example at the top is based on ASP.Net but there is nothing really unusual or non-portable in what I described.

Ambantin, how do you call the regex? Can you show your code?

Gary
Dreamweaver is menu driven
000000.jpg
I got it to work. Initially it failed due to a newline at the end of the regexp in the Find window. Make sure the cursor is at the end of the regexp and that right-cursor does not move to the next line. If so, delete any trailing whitespace.
 User generated image
I have CS3 at the school... at home I only have MX... It worked with CS3 but not MX...
Doesn't work with macromedia dreamweaver mx