Prev: Ruby networking: Errno::ECONNREFUSED: Connection refused -connect(2) on Ubuntu 9.1
Next: [ANN] JRuby 1.4.1 - Fixes XSS Vulnerability in JRuby 1.4.0 -Recommended Upgrade
From: Kevin Austin on 26 Apr 2010 13:28 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 26 Apr 2010 13:35 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 26 Apr 2010 13:54 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 26 Apr 2010 20:05
> >> my problem is that I can't find info about searching for the "*" > >> character. Regexp.escape("*something*") is handy too. Gavin |