Quick Nav:  Online Store   |   Login | Register

Change Format of Commented JavaScript

Rate this topic:

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
Will Strohl
<100 Posts
Posts:88


07/02/2008 9:16 AM  

I want to change commented CDATA blocks in JavaScript from (space added):

//< ![CDATA[
... AND ...
//]]>

To this:

/*< ![CDATA[*/
... AND ...
/*]]>*/

And I also want to change this:

// [single line of comment javascript code]

To this (or remove it altogether):

/* [single line of comment javascript code] */

I having problems getting the RegEx right.  So far, I just break the page.  Here is what I tried for the latter example (extra space added):

 /{2}([^\< \>])+\n

Will Strohl
<100 Posts
Posts:88


07/02/2008 10:04 AM  
Here is my most recent attempt at capturing and replacing the inline javascript comments (no worky):

SEARCHFOR
[^https*:]/{2}([^\< \>]+)([\n\r]+)

REPLACEWITH
/*$1*/$2
John Mitchell
Posts:3352


07/02/2008 12:04 PM  

For the first one:

SearchFor:



(//\s*<!\[CDATA\[)(.*)?(//]]>)

Replace With:



/*<![CDATA[*/$2/*]]>*/

John Mitchell
Posts:3352


07/02/2008 12:21 PM  

for the second one, I'm not sure why you were looking for http at the start of the line, but without doing that it would be:

Search For:



[^:]//(.*?)$

Replace With:



/*$1*/

**Edit, I understand the http thing now, probably to avoid the // after an href, etc. I changed the above to handle that.

Will Strohl
<100 Posts
Posts:88


07/02/2008 1:52 PM  
The CDATA example looked promising, but both scripts are too inclusive and break the page completely. I will work on it again some other time. Thanks.
John Mitchell
Posts:3352


07/02/2008 1:59 PM  

If you can attach an example of a pge where it is getting more than you want then I may be able to make the Regex more targeted.

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
Forums >Snapsis Product Support >PageBlaster > Change Format of Commented JavaScript



ActiveForums 3.7
Powered by: Snapsis Software