Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Parsing web pages (sort of)

by perlcgi (Hermit)
on May 25, 2000 at 19:29 UTC ( #14772=note: print w/replies, xml ) Need Help??

in reply to Parsing web pages (sort of)

# Would like to see the page source but this will work # for one target string per line. # $_ contains mypage.html print $1 if /\s(DE\d{6})/;

Replies are listed 'Best First'.
RE: Re: Parsing web pages (sort of)
by lhoward (Vicar) on May 25, 2000 at 19:30 UTC
    I came up with this code:
    perl -n -e 'while(m/\b(DE\d{6})/g){print "$1\n";}' mypage.html
    There is also this slight variation:
    perl -n -e 'print "$1\n" while(/\b(DE\d{6})/g)' mypage.html
    but I prefer the first because as a general rule I don't like suffixing statments with conditionals except for error handling.

    It is slightly longer but does handle multiple matches in a line and it also breaks apart the output to one "DE" per line.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://14772]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2022-12-06 00:07 GMT
Find Nodes?
    Voting Booth?

    No recent polls found