From: Sebastian probst Eide Date: 2007-04-30T05:55:06+09:00 Subject: Re: Parsing text with regular expression Timothy Hunter wrote: > Sebastian probst Eide wrote: >> I thought I could check by looking for something like this: >> >> text =~ /[[:punct:]]\s?WORD_I_AM_LOOKING_FOR/ >> and if I got something else than 0 as a result it would mean that the >> word is in the beginning of a sentence. But how do I insert a variable >> into the regular expression? > Use #{}, like this > > word = "hello" > > test =~ /[[:punct:]]\s?#{word}/ > > "word" can be any regular expression. Huh... that was the first thing I tried... must have done something else wrong too in the same expression because it didn't work... I'll try again. Thanks Timothy Sebastian -- Posted via http://www.ruby-forum.com/.