From: Timothy Hunter Date: 2007-04-30T05:51:17+09:00 Subject: Re: Parsing text with regular expression 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.