javascript - Matching only one group -


i have following text:

<p>k</p><p><span class="placeholder" code="{yszz}">samsung xyz</span>&nbsp;</p> <p>khgj&nbsp;<span class="placeholder" code="{uidju}">iphone 9k</span>&nbsp;</p></div> 

i want replace span tags respective code attribute. i'm using pattern:

/<span class="placeholder" code="(.*?)">(?:.*)<\/span>/gi 

but it's matching first span last, instead of each span individually. missing?

https://regex101.com/r/fp4ad7/1

thank you

you misses ? . .* greedy default, need make non-greedy adding ? next .*.

<span class="placeholder" code="(.*?)">.*?<\/span>                                          ^                                          | 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -