This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

small regexp to convert a url

Help for those learning Tcl or writing their own scripts.
Post Reply
J
Jagg
Halfop
Posts: 53
Joined: Sat Jan 24, 2004 11:32 am

small regexp to convert a url

Post by Jagg »

Hi,

which regexp do I need to regexp a url like

Code: Select all

http://www.ftd.de/finanzen/maerkte/:zahlungsverzug-die-bonitaet-der-kunden-pruefen/70040990.html#utm_source=rss2&utm_medium=rss_feed&utm_campaign=/finanzen/maerkte
to

Code: Select all

www.ftd.de/article/70040990.html
So
- www.ftd.de is always the same
- look for int value followed by ".html" (here 70040990.html)
- the transform it to "www.ftd.de/article/70040990.html"

Thanks
Last edited by Jagg on Wed May 23, 2012 12:45 pm, edited 2 times in total.
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

summit like this? untested but should do the job

Code: Select all


set url "http://www.url.de/finanzen/maerkte/:zahlungsverzug-die-bonitaet-der-kunden-pruefen/70040990.html#utm_source=rss2&utm_medium=rss_feed&utm_campaign=/finanzen/maerkte"

regexp {.*([0-9]+).html.*} $url match html_id

set new_url "http://www.url.de/article/$html_id.html"

J
Jagg
Halfop
Posts: 53
Joined: Sat Jan 24, 2004 11:32 am

Post by Jagg »

Thanks
Post Reply