Regex help! :)


#1

Hi!

I'm using FoxReplace Firefox extension to enhance forum usage such as creating BBCODE image lists.

Abstractly speaking i have:

http(s)://content.domain/image.ext

I want to covert it to:

[img]http(s)://content.domain/image.ext[/img]

I've found this Regex line that i believe it satisfies the condition but i can't make it to work:

(http(s?):)|([/|.|\w|\s])*\.(?:jpg|gif|png)

I believe this one isn't easy to figure out, any tips or suggestions will be immensely appreciated! :slight_smile:


#2

What does this HTML code have to do with tagging MP3 files?


#3

I've just found this article about regular expression to detect an URL:
http://www.regexguru.com/2008/11/detecting...-block-of-text/
Maybe it can help you to create your own.

DD.20110317.0820.CET


#4

I've found this website useful when playing around with Regexs

http://gskinner.com/RegExr/


#5

Thank you all for the tips!

Kudos goes to ganjaman for introducing me to such a fine tool! It will work as my regex swissknife from now on! :slight_smile:

I kinda figured out the regex and the respective result (FoxReplace):

(((http://www)|(http://)|(www)|(https://))[-a-zA-Z0-9@:%_\+.~#?&//=]+)
\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)

Replace matches with:

[img]$1.$7[/img]

Worked as a charm! :slight_smile:


#6

Countless other programs take advantage of regular expressions besides Mp3Tag. Since there are many people interested about improving their knowledge like me i decided to share the challenge! :slight_smile:


#7
QUOTE (Harakiri @ Mar 17 2011, 14:13) <{POST_SNAPBACK}>
... I kinda figured out the regex and the respective result (FoxReplace):
(((http://www)|(http://)|(www)|(https://))[-a-zA-Z0-9@:%_\+.~#?&//=]+)
\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)

Replace matches with:

[img]$1.$7[/img]

Worked as a charm! :slight_smile:

I have tried your regular expression with Mp3tag ...

$regexp(%URL%,'(((http://www)|(http://)|(www)|(https://))[-a-zA-Z0-9@:%_\+.~#?&//=]+)\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)','(.img.)$1.$7(./img.)')

(Note: Replaced square brackets around IMG BBCODE tags with "(." resp. ".)" to display it here.)

... with the URL ...
http://forums.mp3tag.de/style_emoticons/default/smile.gif
and it seems to work ...

Please offer the public reference (the BBS) where do you apply this functionality.

DD.20110317.1545.CET


#8

Let's say you want to copy all image links from this site with the least possible effort:

:slight_smile:


#9

If I need such functionality, then I use simply my text editor or when just using IE with installed developer tools, press F12, and let me give a link report.

Hmm ... I do not see any relevance to Music and Mp3tag.

It is no good practice for this board to offer picture references pointing to the webpages of other providers. In case of the link will become broken, the image is lost here in the board's article.

Illustrative images should be glued together for ever with the article on this board.
So pictures need to be stored permanently by uploading to this board's server.

DD.20110318.0430.CET


#10

I always thought there was some flexibility to share information regarding regex with Mp3Tag community. I can remove the topic or upload the GIFs to the boards, your call.


#11

this topic is clearly off-topic, for which there would be a extra forum here.

if you want to download all images of a webpage, i recommend you a software called JDownloader. It's a download manager with lots of possiblilities.
You can just copy the whole source code of the page and JDownloader will extract all picture URLs for you.