Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Stuck with RegEx (Parsing whois output)

by marsch (Initiate)
on Sep 29, 2004 at 08:28 UTC ( #394886=note: print w/ replies, xml ) Need Help??

in reply to Stuck with RegEx (Parsing whois output)


Hello folks,

I finally made it, not too good, but proper. I think there ain't no solution for that problem with one single match as I tried, so I'll use this workaround as I may assume there is a finite number of equal key words:

@address = $whois =~ m/(?:\{section1\}(?:\{section[\d]+\})*)\n(?:\S*(? +<!key9):\s+[\S]+[^\n]+\n)+(?:key9:\s+([\S]+[^\n]+)\n)(?:key9:\s+([\S] ++[^\n]+)\n)?(?:key9:\s+([\S]+[^\n]+)\n)?(?:key9:\s+([\S]+[^\n]+)\n)?( +?:(?<!key9):[^\n]+\n)*?/gs; for (my $c = scalar @address; $c > 0; --$c) { pop @address unless defined $address[$c - 1]; }

This is the matched file format:

key6: key6_1

key7: key7_1_section1
key8: key8_1_section1
key9: key9_1_section1
key9: key9_2_section1
key9: key9_3_section1
key10: key10_1_section1
key11: key11_1_section1
key12: key12_1_section1
key16: key16_1_section1
key17: key17_1_section1

key7: key7_1_section2_section3

Comment on Re: Stuck with RegEx (Parsing whois output)
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2015-11-26 20:38 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (707 votes), past polls