From: Peter Jones Date: 2008-05-11T02:55:02+09:00 Subject: Re: how to do this regex substitution? globalrev writes: > i want to replaxe the pattrn consonant o consonant, ie hoh -> h, dad - >> d etc. > > so i have to check that the letter after the letter i am at is o and > the next one is equal to the one i am at. > > so > /qwrtpsdfghjklzxcvbnm/o/qwrtpsdfghjklzxcvbnm isnt true(and doesnt work > anyway). You question is a bit confusing. You said you wanted to replace: consonant o consonant with: consonant Yet, one of your examples is dad, which doesn't fit that pattern. Did you mean "consonant vowel consonant"? Either way, here is one possibility. I'll leave "dad" as an exercise. ,---- | >> "hoh".sub(/([qwrtpsdfghjklzxcvbnm])o\1/, '\1') | => "h" `---- -- Peter Jones [pjones at domain below] pmade inc. - http://pmade.com