How to specify the period "." character when doing a gsub

All-

Plz advise how to specify the period “.” character when doing a gsub.

eg, doing this:

some_object.gsub(/123.456/, “some_string”)

seems to treat the “.” as a wildcard of some kind. I’d like to hit on the actual character.

Thanks!

-ke

‘.’ is indeed a wildcard (or a “metacharater”). It matches anything
except newline (maybe one or two others - see Pickaxe for details).

Escape it with a backslash to match a literal ‘.’.

Gavin

···

On Sunday, December 29, 2002, 2:07:56 PM, Kurt wrote:

All-

Plz advise how to specify the period “.” character when doing a gsub.

eg, doing this:

some_object.gsub(/123.456/, “some_string”)

seems to treat the “.” as a wildcard of some kind. I’d like to hit on the actual character.

Thanks!

-ke

Only the newline unless you’re in multiline mode (ref: Pickaxe pg 61)

···

On Saturday 28 December 2002 10:13 pm, Gavin Sinclair wrote:

‘.’ is indeed a wildcard (or a “metacharater”). It matches anything
except newline (maybe one or two others - see Pickaxe for details).


Bruce R. Williams :: [iusris/#ruby-lang] :: http://www.codedbliss.com

‘It does not require a majority to prevail, but rather an irate,
tireless minority keen to set brush fires in people’s minds.’
– Samuel Adams