Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Array Filter and Lookahead

by AnomalousMonk (Chancellor)
on Nov 20, 2012 at 20:13 UTC ( #1004787=note: print w/replies, xml ) Need Help??

in reply to Re: Array Filter and Lookahead
in thread Array Filter and Lookahead

>perl -wMstrict -le "my @test = ('0 xx', 'xx 0', '0'); ;; my @test_filtered = map { (/(\d+)[\d.]*/g)[-1] || '' } @test; printf qq{'$_' } for @test_filtered; " '' '' ''

Update:  // vice  || does the trick.

Replies are listed 'Best First'.
Re^3: Array Filter and Lookahead
by Kenosis (Priest) on Nov 20, 2012 at 20:29 UTC

    Excellent catch, thank you! Changed disjunct positions...

      Changed disjunct positions...

      But that just causes a problem for strings that have no digits at all, e.g., 'xxx', which daugh016 wants to extract as '' (empty string).

        I think today is two of those days... The //, as you suggested, is best. Thank you, again...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004787]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2018-06-20 19:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.