From: Phrogz Date: 2007-04-10T22:50:10+09:00 Subject: Re: regexp -how to match this? On Apr 10, 7:00 am, Nanyang Zhan wrote: > so ?= makes pattern lookAHEAD. How to make pattern lookBEHIND? http://phrogz.net/ProgrammingRuby/language.html#extensions Zero-width positive and negative lookaheads are supported in Ruby's regexp engine in 1.8. Zero-width lookbehind assertions are not supported by the current regexp engine. (However, they are supported by Oniguruma, the regexp engine used in 1.9 and future builds of Ruby.) > example sentence: > This forum is connected to a mailing list that is read by class="wow">thousands of people. > > question: > how to make a Regexp to match the words followed by the tag? Just because you consume them doesn't mean you have to use them. Use parentheses to saved parts of text extracted by your regular expression. irb(main):001:0> str = 'is read by thousands of people.' => "is read by thousands of people." irb(main):002:0> str[ /<\/span>(.+)/, 1 ] => " of people." irb(main):003:0> %r{(.+)}.match( str ).to_a => [" of people.", " of people."]