View Single Post
  #3 (permalink)  
Old March 6th, 2007, 10:03 AM
CaNNaC CaNNaC is offline
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by ciderpunx
You're nearly there. This will do it:
Code:
if ($str=~m/Men/) {
  $str =~ s/en/an/;
}
Thanks, I know that this will substitute -en- to -an-. This will just change the first -en- in the string to -an-, but I want to change the -en- in the matched reg. expr. In my example (The men in the room looked at the Men in the street), it will change -en- in men to -an-, but as you noticed I matched Men and I didn't change it. So, problem is how to get the content of matched string and change it without changing any other unmatched substring.

Thanks.

Reply With Quote