Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: What's wrong with this regex

by Riales (Hermit)
on Mar 01, 2012 at 15:46 UTC ( #957245=note: print w/ replies, xml ) Need Help??


in reply to Re^2: What's wrong with this regex
in thread What's wrong with this regex

I'm thinking you don't need a beefy regex if that's all you want to do. How about something like this instead:

my $string = '12.34.56.78 asdfasdfasdfasdfasdf'; my $numbers = shift @{[split ' ', $string]}; my @numbers = split '\.', $numbers; use Data::Dumper; print Dumper(@numbers) if $numbers =~ /^[\d.]+$/;

EDIT: Whoops, sorry moritz - I confess to only skimming your answer and didn't notice that you had already suggested using split. Apologies!


Comment on Re^3: What's wrong with this regex
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2014-08-21 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls