Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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)

SOLVED

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

{section1}
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

{section2}{section3}
key7: key7_1_section2_section3
...


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2015-07-30 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls