Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [Jonze] Global or Regex to get name from URL?

Quote Reply
Re: [Jonze] Global or Regex to get name from URL? In reply to
Yes, that's what it does.
Sorry, I've been working so many hours that seems I'm doing a lot of mistakes...

Try this:

Code:
sub {
my $url = shift;
$url= $tags->{'URL'};
if($url=~ m/www\.(.*?)\.com/){
return $1;
}
}


This code will get the tag URL, filter it and give you back only examplesite

Save as a Global under any name than put in your templates <%nome of the global%>

Read more about Regex so you can be able to improve the code and even create your own for other purposes too. Regex is not that complicated as it sounds and will help you a lot.

Note: the m in regex can be excluded but preserve the space between ~ and first /

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Blondies can have brains (sometimes...)

Last edited by:

SaraBem: Mar 1, 2007, 4:49 PM
Subject Author Views Date
Thread Global or Regex to get name from URL? Jonze 4921 Feb 22, 2007, 3:37 PM
Thread Re: [Jonze] Global or Regex to get name from URL?
SaraBem 4797 Mar 1, 2007, 12:38 AM
Thread Re: [SaraBem] Global or Regex to get name from URL?
Jonze 4798 Mar 1, 2007, 11:43 AM
Thread Re: [Jonze] Global or Regex to get name from URL?
SaraBem 4786 Mar 1, 2007, 1:54 PM
Thread Re: [SaraBem] Global or Regex to get name from URL?
Jonze 4811 Mar 1, 2007, 2:48 PM
Thread Re: [Jonze] Global or Regex to get name from URL?
SaraBem 4791 Mar 1, 2007, 3:06 PM
Thread Re: [SaraBem] Global or Regex to get name from URL?
Jonze 4831 Mar 1, 2007, 3:30 PM
Thread Re: [Jonze] Global or Regex to get name from URL?
SaraBem 4787 Mar 1, 2007, 4:41 PM
Thread Re: [SaraBem] Global or Regex to get name from URL?
Jonze 4818 Mar 1, 2007, 5:25 PM
Thread Re: [Jonze] Global or Regex to get name from URL?
Andy 4730 Mar 9, 2007, 1:51 AM
Post Re: [Andy] Global or Regex to get name from URL?
Jonze 4692 Mar 28, 2007, 7:53 AM