# Regular expressions

**URL:** <https://www.ruby-forum.com/t/regular-expressions/187606>\
**Category:** Ruby\
**Created:** [April 26, 2010, 7:28pm UTC](https://www.ruby-forum.com/t/regular-expressions/187606 "2010-04-26T19:28:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![b0rdslide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@b0rdslide](https://www.ruby-forum.com/u/b0rdslide)\
**Post date:** [April 26, 2010, 7:28pm UTC](https://www.ruby-forum.com/t/regular-expressions/187606/1 "2010-04-26T19:28:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![b0rdslide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@b0rdslide](https://www.ruby-forum.com/u/b0rdslide)\
**Post date:** [April 26, 2010, 7:53pm UTC](https://www.ruby-forum.com/t/regular-expressions/187606/2 "2010-04-26T19:53:16Z")

</div>

JesÃºs Gabriel y GalÃ¡n wrote:

> On Mon, Apr 26, 2010 at 7:28 PM, Kevin A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> 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

---

<div class="post-metadata">

**Author:** ![b0rdslide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@b0rdslide](https://www.ruby-forum.com/u/b0rdslide)\
**Post date:** [April 26, 2010, 7:36pm UTC](https://www.ruby-forum.com/t/regular-expressions/187606/3 "2010-04-26T19:36:04Z")

</div>

On Mon, Apr 26, 2010 at 7:28 PM, Kevin A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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.

---

<div class="post-metadata">

**Author:** ![b0rdslide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@b0rdslide](https://www.ruby-forum.com/u/b0rdslide)\
**Post date:** [April 27, 2010, 2:10am UTC](https://www.ruby-forum.com/t/regular-expressions/187606/4 "2010-04-27T02:10:41Z")

</div>

> > > my problem is that I can’t find info about searching for the “\*”  
> > > character.

Regexp.escape(“_something_”) is handy too.

Gavin
