2
   

Perl - regular expression

 
 
View Profile hoachen
 
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";
}
}

}
 
View Profile Monger
 
  1  
Reply Sat 4 Feb, 2006 05:30 pm
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.
0 Replies
 
 

Related Topics

THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
how to earn money in internet - Discussion by rizwanaraj
There is no Wisdom in Crowds - Discussion by ebrown p
CSS Border style colors - Question by meesa
Parallel Processing in PHP - Discussion by alirizwan
 
  1. able2know
  2. » Perl - regular expression
Copyright © 2009 Horizontal Verticals :: Page generated in 0.36 seconds on 11/25/2009 at 03:57:27 Top End