User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 29 Jan 2003, 23:23   #1
King Elessar
Guest
 
Posts: n/a
Another PERL question

Ok, here goes:

I want to find a pattern ( like with the matching operator =~ ) and store part of it as a variable. I think this is very easy, but I can't quite think of what to do.

For example:
Say I wanted to make anything surrounded by a colon ( into a link. So, I want :http://www.planetarion.com: to be replaced with <A href=http://www.planetairon.com>http://www.planetarion.com</a>

I can't just use =~ /:.*:/<A href=>/ or anything like that, becuase that would replace the whole sting.

Sorry if it's confusing, but I can get like that sometimes. Any help you can give will be appreciated.

Thanks,
Elessar
  Reply With Quote
Unread 29 Jan 2003, 23:35   #2
Atamur
Ngisne
 
Join Date: Jul 2001
Location: right here
Posts: 79
Atamur is an unknown quantity at this point
$html =~ s#:(.*):#<a href=$1>$1</a>#

you may want to read perldoc perlre. all sorts of magic can be accomplished with regular expressions...
__________________
down with signatures

Last edited by Atamur; 29 Jan 2003 at 23:52.
Atamur is offline   Reply With Quote
Unread 29 Jan 2003, 23:54   #3
King Elessar
Guest
 
Posts: n/a
Thanks
  Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 09:18.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018