ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: how to do this regex substitution?
by Peter Jones other posts by this author
May 10 2008 10:55AM messages near this date
Re: how to do this regex substitution? | HI.How to install instal qtruby4-1.4.9-mswin32.gem with gem???
globalrev <skanemupp@[...].se>  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
Thread:
Globalrev
botp
Peter Jones

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved