Gossamer Forum
Home : General : Perl Programming :

Reg Expression

Quote Reply
Reg Expression
Hi all,

I try with this code :
Code:
$express = "20000";
$keyword = "\d{5}";
print $keyword;
if($express =~ /\Q$keyword\E/){ print "OK"; }
else{ print "Un match";}

I think it print 'OK' but it print 'Un match'.
Please advise.

Thank in advance,

Beck



Quote Reply
Re: [Beck] Reg Expression In reply to
Try:

$express =~ /^\d{5}$/ ? print 'Yes' : print 'No';
Quote Reply
Re: [RedRum] Reg Expression In reply to
Hi Paul,

I want get the $keyword value from CGI ex : $keyword = $IN->param('keyword');

Thanks,

Beck
Quote Reply
Re: [Beck] Reg Expression In reply to
Hmmm try:

$keyword =~ s/,/\\,/g;
$express =~ m,$keyword, ? print 'OK' : print 'NOT OK';

Last edited by:

RedRum: Oct 23, 2001, 4:47 AM