From: Kevin Austin on
I'm writing a script that is looking through a file for the following
lines


*something*


and replacing it with


*something* - info about the something


my problem is that I can't find info about searching for the "*"
character.

I've been reviewing the regular expression docs and can only find the
usage for "*" and not how to search for *#{stuff}*

any help would be great.
--
Posted via http://www.ruby-forum.com/.

From: Jesús Gabriel y Galán on
On Mon, Apr 26, 2010 at 7:28 PM, Kevin Austin <nitsuanivek(a)comcast.net> wrote:
> I'm writing a script that is looking through a file for the following
> lines
>
>
> *something*
>
>
> and replacing it with
>
>
> *something* - info about the something
>
>
> my problem is that I can't find info about searching for the "*"
> character.
>
> I've been reviewing the regular expression docs and can only find the
> usage for "*" and not how to search for *#{stuff}*

* is a special character for regular expressions, so you have to escape it:

/\*something\*/

Jesus.

From: Kevin Austin on
Jesús Gabriel y Galán wrote:
> On Mon, Apr 26, 2010 at 7:28 PM, Kevin Austin <nitsuanivek(a)comcast.net>
> wrote:
>> *something* - info about the something
>>
>>
>> my problem is that I can't find info about searching for the "*"
>> character.
>>
>> I've been reviewing the regular expression docs and can only find the
>> usage for "*" and not how to search for *#{stuff}*
>
> * is a special character for regular expressions, so you have to escape
> it:
>
> /\*something\*/
>
> Jesus.

Knew it was something stupid

Thanks
--
Posted via http://www.ruby-forum.com/.

From: Gavin Sinclair on

> >> my problem is that I can't find info about searching for the "*"
> >> character.

Regexp.escape("*something*") is handy too.

Gavin