Can I write a pattern that matches "Tampa" or "Florida", or "Tampa Florida"?

Thanks,
Siegfried

-----Original Message-----
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 03, 2005 8:44 AM
To: Jay Savage
Cc: Perl Beginners List
Subject: Re: Search Pattern for Roman Numerals?

On Jun 3, Jay Savage said:

> On 6/3/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
>
>>    s/\b(I|II|...)\b//g;
>
> This isn't going to get them all; it says to match (between word
> boundaries) "I" or "II" or any three non-newlines.  So it will catch
> "I", "II", "III", and "VII".  It will also catch "I" where it's a
> pronoun (assuming this is an english text file), and any three-letter
> words/constructs.

I'm sorry, that regex wasn't meant to be taken literally.  I just didn't 
feel the need to reproduce the alternations *again*.

> I would trysomething like this:
>
> s/\bI(?:I+|V|X)?|VI*|XI*\b//

This will get rid of the "I" in "Ishmael".  Your \b anchors aren't 
effective on the *entire* pattern.  You're matching

   \bI(?:I+|V|X)?
   or
   VI*
   or
   XI*\b

The regex I would use would probably be

   /\b(?:I{1,3}|IV|VI{0,3}|I?X)\b/

-- 
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to