Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Removing digits from a string

by Athanasius (Monsignor)
on Jan 01, 2013 at 13:38 UTC ( #1011152=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Removing digits from a string
in thread Removing digits from a string

s/^\D*\d+// # 'first few digits'

Even if this interpretation is correct (and I agree with erix that it’s unlikely), there is no warrant in the OP to remove the non-digit prefix. So the regex would need to be: s/^(\D*)\d+/$1/. For example:

23:21 >perl -wE "$f = 'xyz20130101Customer100.imp'; $f =~ s/^(\D*)\d+/ +$1/; say $f;" xyzCustomer100.imp 23:22 >

Update (2nd January, 2013):

Thank-you Anonymous Monk for the improvement below using \K: shorter and “much more efficient”, according to perlre. I’ve learned something useful!

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re^4: Removing digits from a string
Select or Download Code
Re^5: Removing digits from a string
by Anonymous Monk on Jan 02, 2013 at 09:11 UTC
    s/^\D*\K\d+//;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-12-21 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (108 votes), past polls