2
   

Perl - regular expression

 
 
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";
}
}

}
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 1,049 • Replies: 1
No top replies

 
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

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Perl - regular expression
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 12/27/2024 at 10:28:28