in reply to Creating a regex to match part of a URL's domain name (was: pattern matching)

first problem is your assigning a scalar to an an array

Should be my $i = "l-12345.in.some.domain.com";

Second, your question seems a bit vague, do you know which two things you need to match?

If so you should be able to say

$i =~/($first)\.($second)/;


Now $first is in $1 and $second is in $2 if they where found.

Of course this doesn't take into account boundaries.
If $first = "dog" and $second ="com" this will match fogdog.com as well. You need to determine what your boundaries are going to be.

-Lee

"To be civilized is to deny one's nature."

Replies are listed 'Best First'.
Re: Re: pattern matching
by strfry() (Monk) on Jun 06, 2001 at 18:23 UTC
    well, say i have www.google.com; i want to match "google".. not "www", and not "com"..
    another example.. if i have ww2.mirror.google.com, i still want it to match only "google"
    does that help any?

    strfry()