RE: [PBML] Removing all \n from a string
- [Please do not top-post -- it makes the conversation difficult to follow]
On Jun 30, Stern, Leon said:
>From: Jeff 'japhy' Pinyan [mailto:japhy@...]Yes: the meaning of "treat string as multiple lines". The documentation
>>On Jun 30, Stern, Leon said:
>>>$string =~ s/\n//gm
>>What is the purpose of the /m modifier there? You don't have any ^ or $
>>anchors in your regex, and those are the ONLY THINGS affected by using /m
>>in a regex.
> Modifier Meaning
> g Match globally, i.e., find all occurrences.
> i Do case-insensitive pattern matching.
> m Treat string as multiple lines.
> o Only compile pattern once.
> s Treat string as single line.
> x Use extended regular expressions.
>Did I miss something?
for pattern matching tells you specifically what is meant by "multiple
lines" and "single line". It tells you exactly what /m and /s do. The
thing is, the "multiple" and "single" mnemonics are poor at best; you
wouldn't think you can use BOTH /m and /s on a regex, but you can.
The long and short of it is this: /m changes how the ^ and $ anchors
match, and THAT IS ALL; /s changes how . matches, and THAT IS ALL.
Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]