开发者

reform URL with GREP

I have a lo开发者_如何转开发t 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=
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜