Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript - String.Match() not working as expected
    text
    copied!<p>Using the following string:</p> <p><a href="http://www.google.com.ar/setprefs?prev=http://www.google.com.ar/&amp;sig=0_Kxz_cp1G52p8pcrDBlMIQhwJAL0%3D&amp;suggon=2" rel="nofollow">http://www.google.com.ar/setprefs?prev=http://www.google.com.ar/&amp;sig=0_Kxz_cp1G52p8pcrDBlMIQhwJAL0%3D&amp;suggon=2</a> https://plus.google.com/?gpsrc=ogpy0&amp;tab=wX <a href="http://www.google.com.ar/webhp?hl=es&amp;tab=ww" rel="nofollow">http://www.google.com.ar/webhp?hl=es&amp;tab=ww</a> http://www.google.com.ar/imghp?hl=es&amp;tab=wi <a href="http://video.google.com.ar/?hl=es&amp;tab=wv" rel="nofollow">http://video.google.com.ar/?hl=es&amp;tab=wv</a> http://news.google.com.ar/nwshp?hl=es&amp;tab=wn <a href="http://translate.google.com.ar/?hl=es&amp;tab=wT" rel="nofollow">http://translate.google.com.ar/?hl=es&amp;tab=wT</a> https://mail.google.com/mail/?tab=wm <a href="http://www.google.com.ar/intl/es/options/" rel="nofollow">http://www.google.com.ar/intl/es/options/</a> http://books.google.com.ar/bkshp?hl=es&amp;tab=wp <a href="http://scholar.google.com.ar/schhp?hl=es&amp;tab=ws" rel="nofollow">http://scholar.google.com.ar/schhp?hl=es&amp;tab=ws</a> http://www.google.com.ar/blogsearch?hl=es&amp;tab=wb <a href="https://www.google.com/calendar?tab=wc" rel="nofollow">https://www.google.com/calendar?tab=wc</a> https://docs.google.com/?tab=wo <a href="https://sites.google.com/?tab=w3" rel="nofollow">https://sites.google.com/?tab=w3</a> http://groups.google.com.ar/grphp?hl=es&amp;tab=wg <a href="http://www.google.com.ar/reader/?hl=es&amp;tab=wy" rel="nofollow">http://www.google.com.ar/reader/?hl=es&amp;tab=wy</a> http://www.google.com.ar/intl/es/options/ <a href="https://accounts.google.com/ServiceLogin?hl=es&amp;continue=http://www.google.com.ar/" rel="nofollow">https://accounts.google.com/ServiceLogin?hl=es&amp;continue=http://www.google.com.ar/</a> http://www.google.com.ar/preferences?hl=es <a href="http://www.google.com.ar/preferences?hl=es-419" rel="nofollow">http://www.google.com.ar/preferences?hl=es-419</a> http://www.google.com.ar/advanced_search?hl=es-419 <a href="http://www.google.com.ar/language_tools?hl=es-419" rel="nofollow">http://www.google.com.ar/language_tools?hl=es-419</a> http://www.google.com/history/optout?hl=es <a href="http://www.google.com.ar/webhp?hl=es-419" rel="nofollow">http://www.google.com.ar/webhp?hl=es-419</a> http://www.google.com.ar/support/websearch/bin/answer.py?answer=186645&amp;form=bb&amp;hl=es-419 <a href="http://www.google.com.ar/intl/es-419/ads/" rel="nofollow">http://www.google.com.ar/intl/es-419/ads/</a> http://www.google.com.ar/services/ <a href="http://www.google.com.ar/intl/es-419/privacy.html" rel="nofollow">http://www.google.com.ar/intl/es-419/privacy.html</a> https://plus.google.com/112209395112018703654 <a href="http://www.google.com.ar/intl/es-419/about.html" rel="nofollow">http://www.google.com.ar/intl/es-419/about.html</a> http://www.google.com/ncr javascript:void(0) </p> <p>And this regex:</p> <p><strong>(http://)(www.){0,1}(google.com.ar)[\S]*</strong></p> <p>This code:</p> <pre><code>var result = links.match(new RegExp("(http://)(www.){0,1}(google.com.ar)[\S]*")); for(var i = 0;i&lt;result.length;i++) { alert(result[i]); } </code></pre> <p>Gives me this output:</p> <ol> <li><a href="http://www.google.com.ar" rel="nofollow">http://www.google.com.ar</a></li> <li>http://</li> <li>www.</li> <li>google.com.ar</li> </ol> <p>I have already tried to test the regex in <a href="http://regexpal.com/" rel="nofollow">http://regexpal.com/</a> and www.regextester.com, and in both cases the highlighted matches are correct, so i guess the problem is with the code. I'm really new with javascript so i can't see the problem. </p> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload