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

x
?
Solved

Remove PHP comments using Dreamweaver Regexes

Posted on 2009-05-08
10
Medium Priority
?
1,295 Views
Last Modified: 2012-06-22
Hello,

I need to remove all of the comments in a php file that is over 4000 lines long.

The comments consist of both types /**/ and //

I have a regular expression for the /**/ part :- [code sec below]

How can i remove the // comments from the document using Dreamweavers (unix like) regexes?
/\*[\S\s]+?(?=\*/)\*/

Open in new window

0
Comment
Question by:wilson1000
  • 6
  • 4
10 Comments
 
LVL 27

Accepted Solution

by:
ddrudik earned 2000 total points
ID: 24339596
Tested with DW CS4:
(?:^|\n)[^\S\r\n]*(?://[^\r\n]*|/\*(?:(?!\*/)[\S\s])*\*/[^\r\n]*)

Open in new window

0
 
LVL 4

Author Comment

by:wilson1000
ID: 24355088
Unfortunately, this crashes Dreamweaver CS3 - I haven't moved over to CS4 as yet because of the transition with plugins.

When the regexe runs it clears only some of the comments but looks as though it gets stuck.

What would cause this?

0
 
LVL 27

Expert Comment

by:ddrudik
ID: 24355245
Not sure, if you can attach a .txt file example of what crashes CS3 I can try it with CS4.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Author Comment

by:wilson1000
ID: 24355585
Thank you ddrudik, file attached...

php-comments.txt
0
 
LVL 4

Author Comment

by:wilson1000
ID: 24355615
Sorry, this isn't enough code please bear with me a second...
0
 
LVL 4

Author Comment

by:wilson1000
ID: 24356083
... try this one ...

php-comments.txt
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 24356118
267 replacements made in CS4.
php-comments.txt
0
 
LVL 4

Author Comment

by:wilson1000
ID: 24356682
Cool, so it works in CS4.

How do you find CS4 in comparison to CS3?
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 24357131
I moved from MX2004 to CS4 so I don't have experience with CS3.  I haven't found anything with CS4 that I dislike but I code more than I design.

Thanks for the question and the points.
0
 
LVL 4

Author Comment

by:wilson1000
ID: 24357207
No trouble, same here from the coding angle - much cleaner & quicker.

Take care
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
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

830 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