[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Simple code needed for Dreamweaver Regular Expression

Posted on 2011-10-09
19
Medium Priority
?
646 Views
Last Modified: 2012-08-13
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..
0
Comment
Question by:ambantin
  • 11
  • 5
  • 3
19 Comments
 
LVL 18

Accepted Solution

by:
Gary Davis earned 1000 total points
ID: 36938815
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
 

Author Comment

by:ambantin
ID: 36938823
didn't work...
0
 

Author Comment

by:ambantin
ID: 36938833
here is another example

"$comp",$num+1,".php"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 36938947
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
 

Author Comment

by:ambantin
ID: 36938955
still not working... ugh
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36938984
Is this for the Find/Replace dialog, or for ReReplace function?
0
 

Author Comment

by:ambantin
ID: 36939028
Find Replace - Dreamweaver MX
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36939104
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36939112
To account for the "+32", try using:

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

Open in new window

0
 

Author Comment

by:ambantin
ID: 36939122
still not found in current document....
0
 

Author Comment

by:ambantin
ID: 36939157
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36939353
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
 

Author Comment

by:ambantin
ID: 36939378
yes i do
0
 

Author Comment

by:ambantin
ID: 36939616
Has anyone got it to work?
0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 36939657
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
 

Author Comment

by:ambantin
ID: 36939709
Dreamweaver is menu driven
000000.jpg
0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 36939870
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
 

Author Comment

by:ambantin
ID: 36940072
I have CS3 at the school... at home I only have MX... It worked with CS3 but not MX...
0
 

Author Closing Comment

by:ambantin
ID: 36940077
Doesn't work with macromedia dreamweaver mx
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question