<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaScript comment removal &#8211; revisited</title>
	<atom:link href="http://james.padolsey.com/javascript/javascript-comment-removal-revisted/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:03:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: caii</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-27718</link>
		<dc:creator>caii</dc:creator>
		<pubDate>Fri, 02 Apr 2010 07:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-27718</guid>
		<description>&quot;the comment problem can’t be solved with regular expressions. &quot;

Maybe can  be solved with regular expressions:

function removeComments(str){
	     return str.replace(reg,function(n,Arg_comments){
                      return Acomments?&#039;&#039;:n
             })
        /* 
    reg=/(comments)&#124;(string)&#124;(regexp)/g
    when  Arg_comments is not empty string , it&#039;s mean comments is found ,replace it with &quot;&quot;,  if not , return the string (like string &quot;&#039;/***/&#039;&quot;  or  &quot;//..&quot;  or /.\/**/ ....) itself .  
   */
}</description>
		<content:encoded><![CDATA[<p>&#8220;the comment problem can’t be solved with regular expressions. &#8221;</p>
<p>Maybe can  be solved with regular expressions:</p>
<p>function removeComments(str){<br />
	     return str.replace(reg,function(n,Arg_comments){<br />
                      return Acomments?&#8221;:n<br />
             })<br />
        /*<br />
    reg=/(comments)|(string)|(regexp)/g<br />
    when  Arg_comments is not empty string , it&#8217;s mean comments is found ,replace it with &#8220;&#8221;,  if not , return the string (like string &#8220;&#8216;/***/&#8217;&#8221;  or  &#8220;//..&#8221;  or /.\/**/ &#8230;.) itself .<br />
   */<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zoltan Hawryluk</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-26810</link>
		<dc:creator>Zoltan Hawryluk</dc:creator>
		<pubDate>Fri, 05 Mar 2010 14:56:56 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-26810</guid>
		<description>Hello there.

Thanks for the post.  You saved me a lot of time - I needed something like this to parse the comments out a CSS style sheet.  Excellent research!</description>
		<content:encoded><![CDATA[<p>Hello there.</p>
<p>Thanks for the post.  You saved me a lot of time &#8211; I needed something like this to parse the comments out a CSS style sheet.  Excellent research!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Rourke</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-24369</link>
		<dc:creator>James Rourke</dc:creator>
		<pubDate>Sun, 15 Nov 2009 23:42:19 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-24369</guid>
		<description>Incidentally, you&#039;ve misspelled &quot;primitives&quot;. ;)</description>
		<content:encoded><![CDATA[<p>Incidentally, you&#8217;ve misspelled &#8220;primitives&#8221;. <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Lepe</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-23635</link>
		<dc:creator>Alberto Lepe</dc:creator>
		<pubDate>Wed, 04 Nov 2009 05:28:59 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-23635</guid>
		<description>I searched in many places but none of those codes worked for me. I wanted to remove starting multiline comments, and your regex worked without problem! (I will give you creds inside my code). Thank you!</description>
		<content:encoded><![CDATA[<p>I searched in many places but none of those codes worked for me. I wanted to remove starting multiline comments, and your regex worked without problem! (I will give you creds inside my code). Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason P</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-22855</link>
		<dc:creator>Jason P</dc:creator>
		<pubDate>Fri, 23 Oct 2009 00:56:54 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-22855</guid>
		<description>try this one to capture both SingleLine and MultiLine Comments: 

/(/\*[\u0000-\uFFFF]*?(?=\*\/)\*/&#124;//[^\u000A&#124;\u000D&#124;\u2028&#124;\u2029]*)/

Works for all of the examples in the comments 

I am sure that [\u0000-\uFFFF] is probably too broad but I could not find a good example of what a unicode &quot;code point&quot; was according to ecmascript spec.</description>
		<content:encoded><![CDATA[<p>try this one to capture both SingleLine and MultiLine Comments: </p>
<p>/(/\*[\u0000-\uFFFF]*?(?=\*\/)\*/|//[^\u000A|\u000D|\u2028|\u2029]*)/</p>
<p>Works for all of the examples in the comments </p>
<p>I am sure that [\u0000-\uFFFF] is probably too broad but I could not find a good example of what a unicode &#8220;code point&#8221; was according to ecmascript spec.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomh</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-22296</link>
		<dc:creator>tomh</dc:creator>
		<pubDate>Thu, 15 Oct 2009 10:02:21 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-22296</guid>
		<description>// comment 
/* comment */ program  //comment

Still no perferct, sorry.
This source doesn&#039;t print &quot;program&quot; as expected, but &quot;/comment&quot;.
But nice try!</description>
		<content:encoded><![CDATA[<p>// comment<br />
/* comment */ program  //comment</p>
<p>Still no perferct, sorry.<br />
This source doesn&#8217;t print &#8220;program&#8221; as expected, but &#8220;/comment&#8221;.<br />
But nice try!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-20305</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sat, 12 Sep 2009 18:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-20305</guid>
		<description>Just been testing it a little more and have found some more bugs. I guess it&#039;s true what they say; the comment problem can&#039;t be solved with regular expressions. 

@Piotr, any minifying program worth its salt won&#039;t screw up that line.</description>
		<content:encoded><![CDATA[<p>Just been testing it a little more and have found some more bugs. I guess it&#8217;s true what they say; the comment problem can&#8217;t be solved with regular expressions. </p>
<p>@Piotr, any minifying program worth its salt won&#8217;t screw up that line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Piotr Wasilewski</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-20284</link>
		<dc:creator>Piotr Wasilewski</dc:creator>
		<pubDate>Sat, 12 Sep 2009 11:44:55 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-20284</guid>
		<description>Hi,

I&#039;ve noticed that you often use this expression: &#039;some_string&#039; + +new Date().
It&#039;s good practice to add brackets &#039;some_string&#039; + (+new Date()) to avoid errors after minifying code.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;ve noticed that you often use this expression: &#8216;some_string&#8217; + +new Date().<br />
It&#8217;s good practice to add brackets &#8216;some_string&#8217; + (+new Date()) to avoid errors after minifying code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-20272</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sat, 12 Sep 2009 07:49:46 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-20272</guid>
		<description>@Corey, Ah.. thanks. Fixed now! :)

@Nicolaj, fixed too, (forgot to add &lt;code&gt;$&lt;/code&gt; to regex)</description>
		<content:encoded><![CDATA[<p>@Corey, Ah.. thanks. Fixed now! <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>@Nicolaj, fixed too, (forgot to add <code>$</code> to regex)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolaj Kirkgaard Nielsen</title>
		<link>http://james.padolsey.com/javascript/javascript-comment-removal-revisted/comment-page-1/#comment-20264</link>
		<dc:creator>Nicolaj Kirkgaard Nielsen</dc:creator>
		<pubDate>Sat, 12 Sep 2009 06:01:52 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1176#comment-20264</guid>
		<description>Hi James...

Nice script. Lord knows I couldn&#039;t have come up with anything in that league. 

It seems that if the last line is a single line comment and the line doesn&#039;t have a break at the end, the script doesn&#039;t recognize the line as a comment. 

&lt;pre lang=&quot;javascript&quot;&gt;
var ok = &quot;not really&quot;; 
// This is a comment
// Shouldn&#039;t this be a comment too?
&lt;/pre&gt;

Doesn&#039;t recognize the last line...</description>
		<content:encoded><![CDATA[<p>Hi James&#8230;</p>
<p>Nice script. Lord knows I couldn&#8217;t have come up with anything in that league. </p>
<p>It seems that if the last line is a single line comment and the line doesn&#8217;t have a break at the end, the script doesn&#8217;t recognize the line as a comment.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> ok <span class="sy0">=</span> <span class="st0">&quot;not really&quot;</span><span class="sy0">;</span> 
<span class="co1">// This is a comment</span>
<span class="co1">// Shouldn't this be a comment too?</span></pre></div></div>

<p>Doesn&#8217;t recognize the last line&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

