Re: show only numbers before, within or after the text

2008-06-30 Thread Brad Baxter
On Jun 28, 11:18 am, [EMAIL PROTECTED] (Luca Villa) wrote: > 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 alp

Re: show only numbers before, within or after the text

2008-06-29 Thread Rob Dixon
Luca Villa wrote: > 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 >

Re: show only numbers before, within or after the text

2008-06-29 Thread Dr.Ruud
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

Re: show only numbers before, within or after the text

2008-06-29 Thread Rob Dixon
sisyphus wrote: > On Jun 29, 1:18 am, [EMAIL PROTECTED] (Luca Villa) wrote: >> 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

Re: show only numbers before, within or after the text

2008-06-29 Thread Rob Dixon
sisyphus wrote: > On Jun 29, 1:18 am, [EMAIL PROTECTED] (Luca Villa) wrote: >> 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

Re: show only numbers before, within or after the text

2008-06-29 Thread sisyphus
On Jun 29, 1:18 am, [EMAIL PROTECTED] (Luca Villa) wrote: > 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 alph

Re: show only numbers before, within or after the text

2008-06-28 Thread John W. Krahn
Luca Villa wrote: 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

Re: show only numbers before, within or after the text

2008-06-28 Thread Gunnar Hjalmarsson
Luca Villa wrote: 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

show only numbers before, within or after the text

2008-06-28 Thread Luca Villa
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

Re: Choosing only numbers from the output

2004-08-04 Thread Christopher J. Bottaro
this is an interesting question in that its not about syntax or a specific problem in perl. here's the algorithm: while there are lines to read from the input read a line split the line into two seperate strings around the colon if both strings are numbers

Re: Choosing only numbers from the output

2004-08-04 Thread Zeus Odin
You are correct. I did not properly look at the regex you passed to split. "Gunnar Hjalmarsson" <[EMAIL PROTECTED]> wrote > > The data as posted had white space trailing some of the digits > > after the colons. > > Yes, but how would that matter? Please read the second sentence in > "perldoc -f sp

Re: Choosing only numbers from the output

2004-08-04 Thread Gunnar Hjalmarsson
Zeus Odin wrote: Gunnar Hjalmarsson wrote: while () { my ($tag, $result) = split /[ :]+/; if ($result =~ /^\d+$/ and $result > 0) { ... The data as posted had white space trailing some of the digits after the colons. Yes, but how would that matter? Please read the se

Re: Choosing only numbers from the output

2004-08-04 Thread Zeus Odin
I think a hash is more apt for this problem, but changing to (an) array(s) is not difficult at all. The data as posted had white space trailing some of the digits after the colons. I found this worked better for me. Your results may vary. ;-) #!/usr/bin/perl use warnings; use strict; my %tag; w

RE: Choosing only numbers from the output

2004-08-04 Thread Yacketta, Ronald
One way would be to split each line using : as the delimiter.. I am sure there are others, but I think split would be the easiest... IMHO From: sudhindra k s Sent: Wed 8/4/2004 5:48 AM To: [EMAIL PROTECTED] Subject: Choosing only numbers from the output Hi I have an output which looks

Re: Choosing only numbers from the output

2004-08-04 Thread John W. Krahn
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 sudhindra k s wrote: | | Hi Hello, | I have an output which looks like this: | | Tag : Result | 146603: | 147020: | 147155: NONE | 147160: | 147232: | 147243: | 147254: none | 147318: | 147341: NONE | 147430

Re: Choosing only numbers from the output

2004-08-04 Thread Gunnar Hjalmarsson
Sudhindra K S wrote: I have an output which looks like this: Do you possibly mean input? ;-) Tag : Result 148200: 148312: 38160 148329: 44139 148444: NONE 148514: 148573: 148697: Now i want to gather all the "Tags" for which the "Result" is a number (but shou

Choosing only numbers from the output

2004-08-04 Thread sudhindra k s
  Hi I have an output which looks like this: Tag : Result 146603: 147020: 147155: NONE 147160: 147232: 147243: 147254: none 147318: 147341: NONE 147430: N/A 147708: 147710: 147729: 147768: 147851: 147921: 147

Re: Only numbers

2003-01-23 Thread R. Joseph Newton
dan wrote: > I want to be able to check if a string contains only a number, no letters, > etc. I have this procedure: Try; if (!($numess =~ /\D/)) { which will reject anything containing a non-digit. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

RE: Only numbers

2003-01-23 Thread Bob Showalter
dan wrote: > I want to be able to check if a string contains only a number, no > letters, etc. I have this procedure: > > if ($numexs =~ /[0-9]/{ > # do something > } > > which doesn't do what I want it to do, I want it to do more or less > this: if ($numexs contains anything other than numbe

RE: Only numbers

2003-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
dan wrote: > Hey again, > > I want to be able to check if a string contains only a number, no > letters, etc. I have this procedure: > > if ($numexs =~ /[0-9]/{ > # do something > } > > which doesn't do what I want it to do, I want it to do more or less > this: if ($numexs contains anything

Re: Only numbers

2003-01-23 Thread Pete Emerson
if ($numexs=~/^\d+$/) { # do this if $numexs contains 1 or more numbers, nothing else } else { } Your regex just checks to make sure there's one number in your entire string. Anchor it at the beginning and the end, and then use a + to say "one or more occurances of" ... if ($numexs=~/^[0-9]+$

RE: Only numbers

2003-01-23 Thread Dan Muey
> Hey again, > > I want to be able to check if a string contains only a > number, no letters, etc. I have this procedure: > > if ($numexs =~ /[0-9]/{ > # do something > } > > which doesn't do what I want it to do, I want it to do more > or less this: if ($numexs contains anything other

Only numbers

2003-01-23 Thread dan
Hey again, I want to be able to check if a string contains only a number, no letters, etc. I have this procedure: if ($numexs =~ /[0-9]/{ # do something } which doesn't do what I want it to do, I want it to do more or less this: if ($numexs contains anything other than numbers) { # do so