Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Removing digits from a string

by erix (Parson)
on Jan 01, 2013 at 10:56 UTC ( #1011138=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^3: Removing digits from a string
by Anonymous Monk on Jan 01, 2013 at 11:02 UTC
    s/^\D*\d+// # 'first few digits'
      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,

        s/^\D*\K\d+//;

      That's likely not the right interpretation of his use of 'truncate', which suggests outer positions, no? But I guess the OP should be able to 'figure' it out ;-)

        That's likely not the right interpretation of his use of 'truncate', which suggests outer positions, no? But I guess the OP should be able to 'figure' it out ;-)

        I kinda doubt the op knows what truncate means, or that the OP would know how to apply any of the answers :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011138]
help
Chatterbox?
[Corion]: But I think my knowledge of unix/Linux datastructures is several decades out of date, so I don't really know what information it keeps on processes
[oiskuu]: The useful bits that relate to your process can be found under /proc/self. What information are you thinking of? Tty name?
[tye]: I just daemonized and getlogin() still knew who I had been.
[tye]: perhaps loginuid ? Not that I concede that something not being in /proc means it is not useful.
[Corion]: tye: That's really interesting, but maybe it is because getlogin() returns the name, or the uid, so if that user has been replaced by another user with the same uid in the meantime, that's no problem to the system...
[davido]: or on ubuntu /var/run/utmp
[Corion]: Otherwise, I would imagine that a user with a process still alive would lock that information in memory.
[davido]: so last -f /var/run/utmp on ubuntu provides similar (though more verbose) info
[oiskuu]: glibc getlogin just does ttyname() and falls back on getutline(); it's not security related at all. (reminds me of sendmail and remote finger services of the naive early spam era)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-06-23 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (554 votes). Check out past polls.