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..
ambantinAsked:
Who is Participating?
 
Gary DavisDir Internet SvcsCommented:
The regex to match the string with 1 to 2 digits following the + is:

"\$comp",\$num\+\d{1,2},"\.php"

The $ + and . need to be escaped with teh backslash. The \d{1,2} means 1 or 2 digits.
The " and , do not need to be escaped.

Gary Davis
0
 
ambantinAuthor Commented:
didn't work...
0
 
ambantinAuthor Commented:
here is another example

"$comp",$num+1,".php"
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
käµfm³d 👽Commented:
Remove the leading and trailing quotes from gardavis' suggestion if you included them in the Find box. That is unless you are trying to find the quotes as well  = )
0
 
ambantinAuthor Commented:
still not working... ugh
0
 
käµfm³d 👽Commented:
Is this for the Find/Replace dialog, or for ReReplace function?
0
 
ambantinAuthor Commented:
Find Replace - Dreamweaver MX
0
 
käµfm³d 👽Commented:
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

0
 
käµfm³d 👽Commented:
To account for the "+32", try using:

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

Open in new window

0
 
ambantinAuthor Commented:
still not found in current document....
0
 
ambantinAuthor Commented:
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

0
 
käµfm³d 👽Commented:
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?
0
 
ambantinAuthor Commented:
yes i do
0
 
ambantinAuthor Commented:
Has anyone got it to work?
0
 
Gary DavisDir Internet SvcsCommented:
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
0
 
ambantinAuthor Commented:
Dreamweaver is menu driven
000000.jpg
0
 
Gary DavisDir Internet SvcsCommented:
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.
 Successful find of RegExp
0
 
ambantinAuthor Commented:
I have CS3 at the school... at home I only have MX... It worked with CS3 but not MX...
0
 
ambantinAuthor Commented:
Doesn't work with macromedia dreamweaver mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.