From: Sean O'Halpin Date: 2005-10-19T03:06:39+09:00 Subject: Re: Regexp problem for template language Using split instead of scan and a slightly different regex: require 'test/unit' TokenizationRegexp = /(\{%.*?%\})+/ # Note different regex class ParsingTest < Test::Unit::TestCase def test_tokenization text = "Hello im liquid this: {% is a tag %} curly brackets like this { may appear in the text } please parse me" assert_equal ["Hello im liquid this: ", "{% is a tag %}", " curly brackets like this { may appear in the text } please parse me"], text.split(TokenizationRegexp) # Note: using split end def test_tokenization_without_curly text = "Hello im liquid this: {% is a tag %}" assert_equal [ "Hello im liquid this: ", "{% is a tag %}"], text.split(TokenizationRegexp) # Note: using split end end Watch out for gmail's line breaks! HTH, Regards, Sean