Michael Glaesemann
6/24/2007 6:21:00 PM
On Jun 24, 2007, at 11:35 , Wyatt Draggoo wrote:
> On Sun, Jun 24, 2007 at 05:45:30PM +0900, Daniel Lucraft wrote:
>
>> irb> str.gsub(/_(.+?)_/m, "<i>\\1</i>")
>
> I like to be very strict with things like quotes (and underscores
> in this case), so I would probably use:
>
> irb> str.gsub(/_([^_]+)_/, "<i>\\1</i>")
From a strictness point of view, what's the difference between /(.+?)
_/ and /([^_]+)_/ in the above? AIUI, they're equivalent. I
personally like the former because if you need to change the _ to
some other character, you only have to make a single character change.
Michael Glaesemann
grzm seespotcode net