Hello all,
I have the following line:
xxx|xxxx|xxxx|xxx.xx|xxx
And i insert the values in an array. I am trying to find out if the field[3] of the array (where field[3]=xxx.xx) has the '.' character.
I am using the code below but it doesn't seem to work.
if($field[3]=~ /./)
{
$serv_info3='MMS';
print("FOUND MMS****************************");
}
It seems that it founds the '.' even if it does not exists.
Any help?
Best regards,
Christos
The period in a regular expression is a wildcard--it matches any character.
I think you can escape it though. Try: ~/\./
ayppa
October 29, 2008, 8:23am
3
Hi,
Dot(.) is an regex wild card character, which is used to match single char in regex. You have to escape (.) using (\.) then only it will match like
if($field[3]=~ /\./)
{
$serv_info3='MMS';
print("FOUND MMS****************************");
}
alternative, without regex
$string = "xxx|xxxx|xxxx|xx.xxx|xxx";
@array = split /\|/ , $string;
if ( (index $array[3], "." ) ==-1) {
print "No dot";
}