regexp - what am i missing???

30 views
Skip to first unread message

Jan Erik Moström

unread,
May 12, 2019, 8:26:26 AM5/12/19
to BBEdit Talk
I want to a simple search on a text like this

---------
<img src="uploads/2019/03eaa90fb4.jpg" width="600" height="600" alt=""
/> lkhlkhl

<img src="uploads/2019/03eaa90fb4.jpg" width="600" height="600" alt=""
/>

<img src="uploads/2019/03eaa90fb4.jpg" width="600" height="600" alt=""
/> <img src="uploads/2019/03eaa90fb4.jpg" width="600" height="600"
alt="" />

---------

where I want to pick out the file paths, in other words four matches.

I first wrote this expression "<img src="(.*)".+?/>" but it matches both
items on the last lines (I don't understand why). I changed it to "<img
src="(.*)"[^>]+/>" but with the same result.

What am missing?

Jean-Christophe Helary

unread,
May 12, 2019, 8:44:21 AM5/12/19
to bbe...@googlegroups.com
Jan,

both <img src="(.*)".+?/> and <img src="(.*)"[^>]+/> have a "(.*)" that matches the longest string, ie from the first " in the line to the last " in the line.

What you want is something like this: <img src="([^\"]*)".+?/>

Jean-Christophe 
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune


Jan Erik Moström

unread,
May 12, 2019, 11:20:07 AM5/12/19
to bbe...@googlegroups.com
On 12 May 2019, at 14:44, Jean-Christophe Helary wrote:

> first " in the line to the last " in the line.

Sigh, I was staring blindly at the last part ... thanks

= jem
Reply all
Reply to author
Forward
0 new messages