문제

I have a lot of URLs like this one

<a href="http://abc123.linkbucks.com"><img src="http://img187.imagevenue.com/loc1115/th_99189_image_122_1115lo.jpg" /></a>

I need to substitute the href part whith the img src part, so it would say

<a href="http://img187.imagevenue.com/loc1115/th_99189_image_122_1115lo.jpg"><img src="http://img187.imagevenue.com/loc1115/th_99189_image_122_1115lo.jpg" /></a>

and then replace the loc???/th_ part with img.php?image= so it would be

<a href="http://img187.imagevenue.com/img.php?image=99189_image_122_1115lo.jpg"><img src="http://img187.imagevenue.com/loc1115/th_99189_image_122_1115lo.jpg" /></a>

Can anyone help me do this with TextWrangler for Mac? The linkbucks links and loc and img bits are all random. I've tried searching but the solutions seem to be very specific and my understanding of regex is so scarce... Thank you!

도움이 되었습니까?

해결책

Edit:

I don't know TextWrangler but I could imagine that following might work:

# 1st step:
search expression: (<a href=")[^"]*("><img src=")([^"]*)"
replacement:       \1\3\2\3"

# 2nd step:
search expression: (<a href="[^"]*)/loc[^/]*/th_
replacement:       \1/img.php?image=
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top