Re: show only numbers before, within or after the text
- From: rvtol+news@xxxxxxxxxxxx (Dr.Ruud)
- Date: Sun, 29 Jun 2008 21:53:41 +0200
Luca Villa schreef:
I have a long text file like this:
324yellow
34house
black
54532
15m21red56
44dfdsf8sfd23
How can I obtain (Perl - Windows/commandline/singleline) the
following?
1) only the numbers at the beginning before some alpha text, like
this:
324
34
15
44
2) only the numbers within the alpha text, like this:
21
8
3) only the numbers at the end after some alpha text, like this:
56
23
perl -wnle 'print;/\d/ and /^(\d*)\D*((?:(?<=\D)\d*(?=\D))?)\D*(\d*)$/
and print "|$1|$2|$3|\n" or print ""' data.txt
324yellow
|324|||
34house
|34|||
black
54532
|54532|||
15m21red56
|15|21|56|
44dfdsf8sfd23
|44|8|23|
--
Affijn, Ruud
"Gewoon is een tijger."
.
- References:
- show only numbers before, within or after the text
- From: Luca Villa
- show only numbers before, within or after the text
- Prev by Date: Re: MIME::QuotedPrint - extra '=' and linebreak?
- Next by Date: Re: show only numbers before, within or after the text
- Previous by thread: Re: show only numbers before, within or after the text
- Next by thread: Re: show only numbers before, within or after the text
- Index(es):
Relevant Pages
|