How do I get Regex to correctly match urls with correct image file names? -



How do I get Regex to correctly match urls with correct image file names? -

i trying update paths of big document using regex , trying match match img src tags include file type jpg, png

i have useded next seek regex correctly match:

<img src="xanne.nnn.pagespeed.ic.u49smximgo.jpg" alt="test"> <img src="xanne.nnn.pagespeed.ic.u49smximgo.png" alt="test">

but matches bottom

<img src="xanne.nnn.pagespeed.ic.u49smximgo.webp" alt="test"> <img src="xanne.nnn.pagespeed.ic.u49smximgo.gif" alt="test">

when utilize next regex:

<img src="(?=.*(jpg|png)?)

any ideas how can match (1 , 2) , not 1,2,3,4?

if want match src attribute value

img src="(?=(.*jpg|.*png))

regex demo

this match whole line has of format shown in 1,2

(?=^<img src=".*(jpg|png)").*$

regex

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -