basic Regex question

G

Greg Hauptmann

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
 
P

Peña, Botp

From: Greg Hauptmann [mailto:[email protected]]=20
# 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=3D/\#\{(.*?)\}/
#=3D> /\#\{(.*?)\}/

s=3D"\#{some_string}"
#=3D> "\#{some_string}"

s.match(re).captures
#=3D> ["some_string"]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top