View Single Post
  #5 (permalink)  
Old March 7th, 2007, 05:33 PM
CaNNaC CaNNaC is offline
Registered User
Join Date: Mar 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Charlie,

Thanks for your help really. I thought the example I gave will solve my problem, but it didn't :(
In the example I just matched a string that I already know -that is Men-, but here is the problem if I write a reg. expr. instead of Men(again it may match Men but we don't know it), then it will match a string that we cannot predict exactly which word it will be.

For example:
my $word = "([a-z]|[A-Z])";
my $str = "I hope we-will-find (a-Solution)";

if($str =~ m/(\()($word+(\-$word+){1,}$word+)/(\))) {
   #here as it is seen from the reg. expr. I will match (a-Solution)
   #and I want to delete - in this matched substring without deleting the others
   #It should be (aSolution) after deletion. But we cannot know the substring that will match before it matches
   #as it is in previous example.
   $str =~ s/\-//;
   #if i write this, this will delete the first -, but not in the (a-solution.)
   #So, how can we tell it should delete the one that it matched in reg. expr.
Thanks for your help.

Reply With Quote