Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Array Filter and Lookahead

by CountZero (Bishop)
on Nov 20, 2012 at 20:13 UTC ( #1004788=note: print w/replies, xml ) Need Help??


in reply to Array Filter and Lookahead

There is more than one way to do it:
use Modern::Perl; my @test = ( "text text text 1 text", "1 text text text 2 text 3", "text 1 text text 2 text", "text text text 1 text 2 3.0", "1 2 3 4 5 6 7 8 9 10 11", "text text 4.5 text text" ); for (@test) { say "$_: $1" if /(\d+)\.?\d*?\D*?$/; }
Output:
text text text 1 text: 1 1 text text text 2 text 3: 3 text 1 text text 2 text: 2 text text text 1 text 2 3.0: 3 1 2 3 4 5 6 7 8 9 10 11: 11 text text 4.5 text text: 4

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004788]
help
Chatterbox?
[1nickt]: Mpph didn;t have twins bu I remember thinking that the "terrible twos" was a misnomer as age 4 seemed to be much more difficult.
LanX 4 kids and wanting to upgrade to 5? wow! ! !
[1nickt]: My lads are 15 and 31 now and both drive me just as crazy as when little, just less frequently.
[LanX]: ;p
[marto]: LanX I'd rather commit sudoku :P
[marto]: trench humour folks, feeling rough.
[marto]: there is never a night when they sleep all the way through, but last night was something else
[marto]: gave in at 3:45 ish and let Charlie watch videos about spitfires, the battle of Britain. He's plane crazy

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-11-18 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?