Wong, Danny H. wrote:

> Hi Perl Gurus,
>       I have a regular expression question.
> I have a variable
> $Number = "1.2.3.4"
> 
> When I use the variable $Number as part of my regular expression, the
> "." character gets interpret as any character. How do I make it a
> literal "." that I'm searching for?  
> Example:
> $String = "This is a numeric string 1.2.3.411 embedded within another
> string 3.4.5.6"
> $String =~ m/$Number/I; This returns "1.2.3.411" true, when it
> shouldn't.

Easiest way is
        $String =~ m/\Q$Number\E/i;

You can also use quotemeta (look it up) or escape your .'s in $number (ie: 
"1\.2\.3\.4").

PS:  It's not good etiquette to CC people who already read the list.
-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to