chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] perlcre /i, /m. /s and /x modifiers


From: John Cowan
Subject: Re: [Chicken-hackers] perlcre /i, /m. /s and /x modifiers
Date: Tue, 10 Jul 2007 00:04:20 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Tony Sidaway scripsit:

> Is anybody familiar enough with the code to know how to use the /i,
> /m. /s and /x modifiers with regular expressions?

You can also incorporate them directly into the regex using the syntaxes
"(?i)", "(?m)", "(?s)", and "(?x)".

Here's what they do.  /i causes all matches to be case-insensitive.
/m means that ^ and $ match after and before each newline as well at the
beginning and the end of the string.  /s means that . matches a newline as
well as any other character.  /x means that whitespace and Perl comments
(from # to newline) are ignored.

> I need to match a pattern across the whole of a multi-line character 
> string.

The simplest way is to use \A and \Z, which mean the beginning and the
end of the string independent of whether /m is present.  You'll need /s
if you want to allow . to match a newline, though.

-- 
Mos Eisley spaceport.  You will never           John Cowan
see a more wretched hive of scum and            address@hidden
villainy -- unless you watch the                http://www.ccil.org/~cowan
Jerry Springer Show.   --georgettesworld.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]