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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -