Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

how to write 0 to 10 in reg exp.
Hi,
How do I write the expression, if the variable match between 0 to 10? Below 
is the wrong expression I wrote which is suppose to be if $eightdecks match 
0 to 10. So i want the answer to be yes.
Thanks

my $eightdecks = 6;

if($eightdecks =~ /[0-10]/){
print "Yes match\n";
}else{print "no"};

Report this thread to moderator Post Follow-up to this message
Old Post
itshardtogetone@hotmail.com
04-02-08 09:30 AM


Re: how to write 0 to 10 in reg exp.
try this one:

# perl -Mstrict -le 'my $x=shift; print 1 if $x=~/^[0-9]$|^10$/'  10
1



On 4/2/08, itshardtogetone@hotmail.com <itshardtogetone@hotmail.com> wrote:
> Hi,
> How do I write the expression, if the variable match between 0 to 10? Belo
w is the wrong expression I wrote which is suppose to be if $eightdecks matc
h 0 to 10. So i want the answer to be yes.
> Thanks
>
> my $eightdecks = 6;
>
> if($eightdecks =~ /[0-10]/){
>  print "Yes match\n";
> }else{print "no"};

Report this thread to moderator Post Follow-up to this message
Old Post
Jeff Pang
04-02-08 09:30 AM


RE: how to write 0 to 10 in reg exp.
Here is the code to match 0 to 10 using regex.


use warnings;
use strict;

print "Enter any number:";
my $input = <STDIN>;
chomp($input);

if($input=~ m/^10$|^[0-9]$/)
{
print "matched";
}
else
{
print "not matched";
}


Hope it helps.


-----Original Message-----
From: itshardtogetone@hotmail.com [mailto:itshardtogetone@hotmail.com]
Sent: Wednesday, April 02, 2008 2:09 PM
To: beginners@perl.org
Subject: how to write 0 to 10 in reg exp.

Hi,
How do I write the expression, if the variable match between 0 to 10? Below
is the wrong expression I wrote which is suppose to be if $eightdecks match
0 to 10. So i want the answer to be yes.
Thanks

my $eightdecks = 6;

if($eightdecks =~ /[0-10]/){
print "Yes match\n";
}else{print "no"};


Report this thread to moderator Post Follow-up to this message
Old Post
Sanket Vaidya
04-02-08 01:08 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.