RE Perl Pattern matching
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.perl.misc Profile…
 Up
RE Perl Pattern matching         


Author: Deepan Perl XML Parser
Date: Apr 1, 2008 22:23

Hi,
I am having a string say $str, the value of it is as
below:

HTTP/1.1 200 OK



int.juniper.net">DOCFGJEAKNOMBLHCGEMOIMBA





private


deflate


text/html


Wed, 26 Mar 2008 04:48:16 GMT


Concealed by Juniper Networks Redline EX header>

ASPSESSIONIDSQDCBDBA=DOCFGJEAKNOMBLHCGEMOIMBA; path=/


chunked


Accept-Encoding, User-Agent
Show full article (2.00Kb)
7 Comments
Re: RE Perl Pattern matching         


Author: Ben Bullock
Date: Apr 1, 2008 22:30

On Apr 2, 2:23 pm, Deepan Perl XML Parser gmail.com> wrote:
> if( $str =~ m## )
> {
> print $1;
>
> }
>
> But not getting anything. Can anyone find out the fault in it?

You need an "s" at the end:

if( $str =~ m##s )

See http://perldoc.perl.org/perlre.html#Modifiers
no comments
Re: RE Perl Pattern matching         


Author: Deepan Perl XML Parser
Date: Apr 1, 2008 22:35

On Apr 2, 10:30 am, Ben Bullock gmail.com> wrote:
> On Apr 2, 2:23 pm, Deepan Perl XML Parser gmail.com> wrote:
>
>> if( $str =~ m## )
>> {
>> print $1;
>
>> }
>
>> But not getting anything. Can anyone find out the fault in it?
>
> You need an "s" at the end:
>
> if( $str =~ m##s )
>
> Seehttp://perldoc.perl.org/perlre.html#Modifiers

Thank You Ben!
no comments
Re: Perl Pattern matching         


Author: Mirco Wahab
Date: Apr 2, 2008 00:44

Deepan Perl XML Parser wrote:
> Now i want to get everything between "
>>" [ie i need to capture the CDATA section]and i am using the
> below code
>
> if( $str =~ m## )
> {
> print $1;
> }

Your expression is (besides the /s modifier) perfectly valid
but I'd like to make an additional remark. You could strip
the newline characters (if any) and extract more than one
CDATA section, sth. like:
Show full article (0.90Kb)
no comments
Re: RE Perl Pattern matching         


Author: Chris Mattern
Date: Apr 2, 2008 08:53

On 2008-04-02, Deepan Perl XML Parser gmail.com> wrote:
> Hi,
>
>
> But not getting anything. Can anyone find out the fault in it?

You're trying to parse XML with regular expressions. Don't do that.
Perl has a large selection of excellent modules for processing XML.
Use them.

--
Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities
no comments
Re: RE Perl Pattern matching         


Author: Ben Bullock
Date: Apr 2, 2008 15:16

On Wed, 02 Apr 2008 10:53:34 -0500, Chris Mattern wrote:
> You're trying to parse XML with regular expressions. Don't do that.
> Perl has a large selection of excellent modules for processing XML. Use
> them.

Chris, do you talk like that to people in real life, or is it just the
internet?
no comments
Re: RE Perl Pattern matching         


Author: Charlton Wilbur
Date: Apr 3, 2008 09:25

>>>>> "BB" == Ben Bullock gmail.com> writes:
BB> On Wed, 02 Apr 2008 10:53:34 -0500, Chris Mattern wrote:
>> You're trying to parse XML with regular expressions. Don't do
>> that. Perl has a large selection of excellent modules for
>> processing XML. Use them.
BB> Chris, do you talk like that to people in real life, or is it
BB> just the internet?

When you've said the same thing over and over to people who aren't
getting it, there is a clear temptation to speak slowly, with short
sentences and short words.

Charlton

--
Charlton Wilbur
cwilbur@chromatico.net
no comments
Re: RE Perl Pattern matching         


Date: Apr 9, 2008 14:40

On Wed, 02 Apr 2008 22:16:09 +0000, Ben Bullock wrote:
> On Wed, 02 Apr 2008 10:53:34 -0500, Chris Mattern wrote:
>
>
>> You're trying to parse XML with regular expressions. Don't do that.
>> Perl has a large selection of excellent modules for processing XML. Use
>> them.
>
> Chris, do you talk like that to people in real life, or is it just the
> internet?

I do. Even (especially?) if someone is new around here and is making a
mistake thousands have made before.

M4
no comments