0

I have this code

<img style="border:0px;" src="http://example.com/images/items/Start.gif" ONMOUSEOVER="itempopup(event,'83560729')" ONMOUSEOUT="kill()" onclick="removeItem('83560729',219395,0);document.getElementById('tab8').innerHTML=''"><img style="border:0px;" src="http://example.com/images/items/Start_init.gif" ONMOUSEOVER="itempopup(event,'83014012')" ONMOUSEOUT="kill()" onclick="removeItem('83014012',219395,0);document.getElementById('tab8').innerHTML=''"><img style="border:0px;" src="http://example.com/images/items/start.gif" ONMOUSEOVER="itempopup(event,'82196324')" ONMOUSEOUT="kill()" onclick="removeItem('82196324',219395,0);document.getElementById('tab8').innerHTML=''"> </div>

Also posted here: https://regex101.com/r/gM2yD7/1 And I have a problem in finding all the matches. I tried in different ways to find the 3 matches but is what get me close: items/[sS]tart.*itempopup(event,\'(\d+) , but instead of finding all 3, he gets only 1. Can anyone help me with suggestions?

BlueDotRo
  • 101
  • 1
  • 2
  • 9
  • `.*` is greedy, so Change your regex to `items\/[sS]tart.*?itempopup\(event,\'(\d+)` . Please ask a complicate question :-) – Avinash Raj Jan 12 '15 at 16:06

1 Answers1

1

To make .* non-greedy (lazy), you should use ?:

items\/[sS]tart.*?itempopup\(event,\'(\d+)

.* is greedy means that the engine repeats it as many times as it can, so the regex continues to try to match the . with next characters, resulting with matching the whole tokens, then it'll backtrack until it matches the following tokens - meaning that it'll continue to match everything and finally matches itempopup(event,\'(\d+)

Maroun
  • 94,125
  • 30
  • 188
  • 241