[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Pattern based substitution

Gavin Kistner

10/16/2006 5:29:00 PM

From: Daniel Mircea
> How does pattern based substitution works ?

See
http://phrogz.net/ProgrammingRuby/tut_stdtypes.html#regulare...
particularly the section near the end of that page titled "Pattern-Based
Substitution".

> For example, how does textilize replace all occurrences of
> *hello world*
> with <strong>hello world</strong> ?

Here's a simple example (probably not what Textilize uses):
source.gsub( /\*([^*]+)\*/, '<strong>\\1</strong>' )