Re: Regarding reg. exp.

2008-10-14 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > if ($trig_np =~ m/\d,{1}\d|\d\s{1}\d/) As long as you understand that "\s" matches SPC, TAB, CR, NL and several other characters, and "\d" matches [0-9] and many other characters, and how one day that will bite you, feel free to use "\s" and "\d". (I would use neithe

RE: Regarding reg. exp.

2008-10-14 Thread Irfan.Sayed
Thanks really -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2008 6:31 PM To: Perl Beginners Cc: Sayed, Irfan (Cognizant) Subject: Re: Regarding reg. exp. [EMAIL PROTECTED] wrote: > From: Rob Dixon [mailto:[EMAIL PROTECTED] >> [EMAIL

Re: Regarding reg. exp.

2008-10-14 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > From: Rob Dixon [mailto:[EMAIL PROTECTED] >> [EMAIL PROTECTED] wrote: >>> >>> I have a string and I need to parse that string to check whether it is >>> in required format or not. I have a Perl script which ask for user >>> input. I have mentioned in the Perl script that

Re: Regarding reg. exp.

2008-10-14 Thread Rob Dixon
Dr.Ruud wrote: > Rob Dixon schreef: > >> my $re = qr/^ >> \d+ >> (?: >>(?:,\d+)* | (?: \d+)* >> ) >> $/x; >> >> chomp (my $input = <>); >> >> if ($input =~ $re) { >> print "ok\n"; >> } >> else { >> print "invalid\n"; >> } > > One problem: the space in "(?: \d+)*" is eaten by the x-m

RE: Regarding reg. exp.

2008-10-14 Thread Irfan.Sayed
, 2008 5:16 PM To: Sayed, Irfan (Cognizant) Cc: [EMAIL PROTECTED]; beginners@perl.org Subject: Re: Regarding reg. exp. [EMAIL PROTECTED] пишет: > Because I want comma (,) exactly once > > -Original Message- > From: Vyacheslav Karamov [mailto:[EMAIL PROTECTED] > Sent: Tuesday, O

Re: Regarding reg. exp.

2008-10-14 Thread Vyacheslav Karamov
[EMAIL PROTECTED] пишет: Because I want comma (,) exactly once -Original Message- From: Vyacheslav Karamov [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2008 4:41 PM To: Sayed, Irfan (Cognizant) Cc: [EMAIL PROTECTED]; beginners@perl.org Subject: Re: Regarding reg. exp. [EMAIL

RE: Regarding reg. exp.

2008-10-14 Thread Irfan.Sayed
Because I want comma (,) exactly once -Original Message- From: Vyacheslav Karamov [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2008 4:41 PM To: Sayed, Irfan (Cognizant) Cc: [EMAIL PROTECTED]; beginners@perl.org Subject: Re: Regarding reg. exp. [EMAIL PROTECTED] пишет: >

Re: Regarding reg. exp.

2008-10-14 Thread Vyacheslav Karamov
[EMAIL PROTECTED] пишет: if ($trig_np =~ m/\d,{1}\d|\d\s{1}\d/) this what I did. Hi! Why have you used {1} quantifier? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

RE: Regarding reg. exp.

2008-10-14 Thread Irfan.Sayed
if ($trig_np =~ m/\d,{1}\d|\d\s{1}\d/) this what I did. -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Monday, October 13, 2008 6:49 PM To: Perl Beginners Cc: Sayed, Irfan (Cognizant) Subject: Re: Regarding reg. exp. [EMAIL PROTECTED] wrote: > > I have a stri

Re: Regarding reg. exp.

2008-10-13 Thread Dr.Ruud
Rob Dixon schreef: > my $re = qr/^ > \d+ > (?: >(?:,\d+)* | (?: \d+)* > ) > $/x; > > chomp (my $input = <>); > > if ($input =~ $re) { > print "ok\n"; > } > else { > print "invalid\n"; > } One problem: the space in "(?: \d+)*" is eaten by the x-modifier. I would normally use [[:blan

Re: Regarding reg. exp.

2008-10-13 Thread Rob Coops
On Mon, Oct 13, 2008 at 2:49 PM, <[EMAIL PROTECTED]> wrote: > > Hi All, > > > > I have a string and I need to parse that string to check whether it is > in required format or not. I have a Perl script which ask for user > input. I have mentioned in the Perl script that input should be in the > fol

Re: Regarding reg. exp.

2008-10-13 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > I have a string and I need to parse that string to check whether it is > in required format or not. I have a Perl script which ask for user > input. I have mentioned in the Perl script that input should be in the > following format. > > For example:- 1,2,3 OR 1 2 3 >

Re: Regarding reg. exp.

2008-10-13 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > For example:- 1,2,3 OR 1 2 3 I assume it should also work on 132,45,16 but should it also work on 132, 45, 16 or on 0132,-45,16E0,0x03 etc. ? See Regexp::Common. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL P

Regarding reg. exp.

2008-10-13 Thread Irfan.Sayed
Hi All, I have a string and I need to parse that string to check whether it is in required format or not. I have a Perl script which ask for user input. I have mentioned in the Perl script that input should be in the following format. For example:- 1,2,3 OR 1 2 3 Which means that delimit