Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl Regex

by AlexTape (Monk)
on Oct 10, 2013 at 11:41 UTC ( #1057724=note: print w/replies, xml ) Need Help??


in reply to Perl Regex

maybe thats what you looking for?
#!"C:\perl\bin\perl.exe" -w # pragma use strict; use warnings; use diagnostics; # includes use Data::Dumper; my $string = '[-3|1|29x250+46+26|200+300+464|Get][-3|1|29x250+46+26|200+300+464|Get +][-3|1|29x250+46+26|200+300+464|Get]'; sub getValues($) { my (@foo,@bar); foreach ( split( '\]\[', $_[0] ) ) { m/(\|[0-9x+]*){2}/g; push(@foo,$1); } foreach ( @foo) { m/\|(\d*)\w(\d*)\+(\d*)\+(\d*)/g; push(@bar, [ $1, $2, $3, $4 ] ); } return \@bar; } print Dumper getValues($string);
result will be
$VAR1 = [ [ '29', '250', '46', '26' ], [ '29', '250', '46', '26' ], [ '29', '250', '46', '26' ] ];
$perlig =~ s/pec/cep/g if 'errors expected';

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2022-10-05 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (22 votes). Check out past polls.

    Notices?