# Basic Regex question

**URL:** <https://www.ruby-forum.com/t/basic-regex-question/148785>\
**Category:** Ruby\
**Created:** [September 17, 2008, 3:34am UTC](https://www.ruby-forum.com/t/basic-regex-question/148785 "2008-09-17T03:34:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 17, 2008, 3:34am UTC](https://www.ruby-forum.com/t/basic-regex-question/148785/1 "2008-09-17T03:34:30Z")

</div>

dumb question perhaps, but how do I do a Ruby based regex expression  
that takes the following as input and produces the following as  
output:

INPUT: “#{some\_string}” # or perhaps if the # needs escaping this  
should be “#{some\_string}”  
OUTPUT: “some\_string”

i.e. what do I put in: “#{some\_string}”.match("???")

thanks in advance

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 17, 2008, 3:45am UTC](https://www.ruby-forum.com/t/basic-regex-question/148785/2 "2008-09-17T03:45:05Z")

</div>

From: Greg H. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# dumb question perhaps, but how do I do a Ruby based regex expression

# that takes the following as input and produces the following as

# output:

# INPUT: “#{some\_string}” # or perhaps if the # needs escaping this

# should be “#{some\_string}”

# OUTPUT: “some\_string”

# i.e. what do I put in: “#{some\_string}”.match(“???”)

something fr,

re=/#{(._?)}/  
#=\> /#{(._?)}/

s=“#{some\_string}”  
#=\> “#{some\_string}”

s.match(re).captures  
#=\> [“some\_string”]

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 17, 2008, 4:11am UTC](https://www.ruby-forum.com/t/basic-regex-question/148785/3 "2008-09-17T04:11:25Z")

</div>

excellent - thanks heaps
