views:

736

answers:

1

Hi this is my pice of code:

                    <div style="overflow: hidden; width: 445px;">[IMG]http://i29.tinypic.com/mydog.png[/IMG] tak si to http://i29.tinypic.com/mycat.png  Lorem ipsum loremai <img width="15" border="0" align="middle" src="images/smejo.gif" valign="middle"/> <img src=http://www.example.com/index.png alt> <img src="http://www.example.com/index.png" alt>     <a href="#reakcia" title="reagovat na temu"><span class="poradna-tl-reaguj"><reaction> </span></a></div>
     </td>        </tr><img src=http://www.example.com/index.png alt><img src="http://www.example.com/index.png" alt>

and i need regex pattern to replace ONLY text image links with image without touch of inner url tags. But i can't use "Lookbehind" or possessive quantifiers because JS don't support them=/ So i want to catch only "http://i29.tinypic.com/mydog.png" and "http://i29.tinypic.com/mycat.png".

I using array method to replacing (will be greasemonkey script.) Many Thanks

A: 

...whole day i cant solved this and now after few minutes...

Answer:

((?:(?:https?|ftp|file)://|www.|ftp.)[-A-Z0-9+&@#/%=~|$?!:,.][A-Z0-9+&@#/%=~_|$]+.(jpg|png|gif|jpeg|bmp))(?!([^<]+)?>)

The trailing part of a URL is not necessarily related to the filetype; there is no reason an image resource has to end with .gif/.jpeg/etc.
bobince