in reply to Re: converting an arbitrary string into a hash based on a pattern
in thread converting an arbitrary string into a hash based on a pattern
I just love regexes. Try to implement that in VB!use strict; use Data::Dumper; my %hash; $_="ABCD----[this] fgab [that] BFTE-- [other] AB CD EF---- [foo] +FOO[this][that][other] BAR []"; while ( /\G\s*([\w ]+)[\s-]*\[([\w\[\]]*)\]/g ) { $hash{$1}=$2; $hash{$1} =~ s/\]\[//g; } print Dumper (\%hash); #$VAR1 = { # 'BAR ' => '', # 'fgab ' => 'that', # 'ABCD' => 'this', # 'BFTE' => 'other', # 'FOO' => 'thisthatother', # 'AB CD EF' => 'foo' # };
|
|---|