Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

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 avoiding work at the Monastery: (3)
As of 2018-10-18 03:07 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (99 votes). Check out past polls.