Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show only numbers before, within or after the text

Status
Not open for further replies.

mailint1

Technical User
Nov 10, 2007
13
IT
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
 
[ol][li]/^(\d+)\w/[/li][li]/\w(\d+)\w/[/li][li]/\w(\d+)$/[/li][/ol]$1 will be set to the value you want in each case.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top