Reply
Mon 25 Jul, 2005 10:04 am
I am trying to do the regular expression. The problem is ... hard to describe here. Example
$dash_s =0;
#if the telephone number match this regular expression then print it out
#1-123-234-9876
if ($data =~ /[\s]\b[1-9]{1}\-?\b[0-9]+\-?\b[0-9]+\-?\b[0-9]+/gcx)
{
#print "$&\n"; #
$nospace = $&;
$nospace =~ s/\s+//g;
print "$nospace\n";
THE PROBLEM IS HERE, I ALSO HAVE ANOTHER OPTION TO FIND THIS NUMBER IF THE '-whatever' OPTION FROM THE COMMAND-LINE (-s filename for compile) IS SPECIFY BUT THIS TIME I WILL REMOVE THE 1-
THE FOLLOWING CODE WILL NOT WORK!
if($dash_s)
{
if ($data =~ /[\s]\b[1-9]{1}\-?\b[0-9]+\-?\b[0-9]+\-?\b[0-9]+/gcx) #1-123-456-7890
{
$nospace =~s/^1-//;
print $nospace\n";
}
}
}
Those are very poorly written regexes, and will match more than what you described you want them to match. It's not very clear what you're trying to do though. I know this thread is old, but should you come back to it I can at least help you with the regular expressions.