<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://regexadvice.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Platform Differences</title><link>http://regexadvice.com/forums/70/ShowForum.aspx</link><description>Discuss differences in Regular Expression implementation across platforms (.NET, Java, JavaScript, Perl, PHP, etc.)</description><dc:language>en</dc:language><generator>CommunityServer 2.1 (Build: 60809.935)</generator><item><title>Re: Python versus Javascript Regex</title><link>http://regexadvice.com/forums/thread/84968.aspx</link><pubDate>Mon, 16 Apr 2012 15:31:44 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:84968</guid><dc:creator>Stevezilla00</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/84968.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=70&amp;PostID=84968</wfw:commentRss><description>Your analysis of the first and second passes is correct. However, this isn&amp;#39;t really a browser issue--it follows the&amp;nbsp;ECMAScript&amp;nbsp;specification. And although it&amp;#39;s true that the result is undefined because at the end you&amp;#39;re left with a nonparticipating capturing group, the reason things end up that way is more specific. I&amp;#39;ve previously discussed it under the heading &amp;quot;Change the behavior of backreference resetting during subpattern repetition&amp;quot; at&amp;nbsp;
&lt;a href="http://blog.stevenlevithan.com/archives/fixing-javascript-regexp"&gt;http://blog.stevenlevithan.com/archives/fixing-javascript-regexp&lt;/a&gt;</description></item><item><title>Re: Python versus Javascript Regex</title><link>http://regexadvice.com/forums/thread/82098.aspx</link><pubDate>Sat, 14 May 2011 19:05:06 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:82098</guid><dc:creator>mash</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/82098.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=70&amp;PostID=82098</wfw:commentRss><description>&lt;p&gt;This is actually a browser issue in how they choose to implement their JavaScript regex engine.&amp;nbsp; For groups that don&amp;#39;t participate in the match they either return null or undefined. For your pattern in the first pass the &amp;quot;A&amp;quot; match and the second group isn&amp;#39;t used, the qualifier cause the entire pattern to be run again resetting the groups, second pass the first group doesn&amp;#39;t participate so it return undefined.&amp;nbsp; &lt;/p&gt;&lt;p&gt;This is just one of many differences across platforms.&amp;nbsp; For a much deeper explantion of the issue see &lt;a href="http://blog.stevenlevithan.com/archives/npcg-javascript"&gt;http://blog.stevenlevithan.com/archives/npcg-javascript&lt;/a&gt; &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Python versus Javascript Regex</title><link>http://regexadvice.com/forums/thread/82041.aspx</link><pubDate>Fri, 13 May 2011 08:46:29 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:82041</guid><dc:creator>pelinquin</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/82041.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=70&amp;PostID=82041</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;The following code in Python returns what I expect: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;m = re.match(r&amp;#39;(?:(A+)|(B+))+&amp;#39;,&amp;#39;AB&amp;#39;)&lt;/p&gt;&lt;p&gt;print (m.group(),m.group(1),m.group(2)) -&amp;gt; (&amp;#39;AB&amp;#39;, &amp;#39;A&amp;#39;, &amp;#39;B&amp;#39;)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;But in Javascript, I&amp;#39;v got a non expected &amp;#39;undefined&amp;#39; &amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;p&gt;var m = /(?:(A+)|(B+))+/.exec(&amp;#39;AB&amp;#39;);&lt;/p&gt;&lt;p&gt;alert (m[0] + &amp;#39;,&amp;#39; + m[1] + &amp;#39;,&amp;#39; + m[2]);&amp;nbsp;&amp;nbsp; -&amp;gt; &amp;nbsp; AB,undefined,B&lt;/p&gt;&lt;p&gt;Could you explain the js behavior and how to fix it to have Python like result.&lt;/p&gt;&lt;p&gt;Thank you &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>