【发布时间】:2011-04-10 11:48:54
【问题描述】:
这是我尝试使用 ruby 捕获的测试字符串:
<?lang
this_should_be_captured();
and_also_this();
and_this();
?>
this text should NOT be captured
<?lang this_should_also_be_captured(); ?>
当我使用这个正则表达式时:
(<\?lang(\n|.)*\?>)
匹配捕获所有内容(包括我不想要的部分:“不应捕获此文本”),如 http://rubular.com/r/qSOOzq6HAx 所示。
如何正确捕获两个不同的块而不捕获我不想要的?
【问题讨论】:
标签: ruby-on-rails ruby regex