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/.
* is a special character for regular expressions, so you have to escape it:
/\*something\*/
Jesus.
···
On Mon, Apr 26, 2010 at 7:28 PM, Kevin Austin <nitsuanivek@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}*
Jesús Gabriel y Galán wrote:
···
On Mon, Apr 26, 2010 at 7:28 PM, Kevin Austin <nitsuanivek@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/\.
GS1
(GS)
4
>> my problem is that I can't find info about searching for the "*"
>> character.
Regexp.escape("*something*") is handy too.
Gavin