in reply to Creating a regex to match part of a URL's domain name (was: pattern matching)
Here's the regex approach:($domain) = split '/', $string; $wanted = (split /\./, $domain)[-2]; # or $wanted = (split /\./, (split '/', $string)[0])[-2];
($wanted) = $string =~ m{ ( [^.]+ ) # save the non-. sequence to $1 \. # . [^./]+ # the final non-. non-/ sequence (?: / | $) # / or the end of the string }x;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: pattern matching
by strfry() (Monk) on Jun 06, 2001 at 19:50 UTC | |
by japhy (Canon) on Jun 06, 2001 at 19:55 UTC | |
by strfry() (Monk) on Jun 06, 2001 at 20:15 UTC | |
by japhy (Canon) on Jun 06, 2001 at 20:26 UTC | |
by strfry() (Monk) on Jun 06, 2001 at 20:55 UTC | |
| |
by strfry() (Monk) on Jun 06, 2001 at 21:21 UTC | |
|
Re: Re: pattern matching
by strfry() (Monk) on Jun 06, 2001 at 18:48 UTC |