Ruby regex提取2个标签之间的内容

时间:2018-06-24 17:33:05

标签: ruby regex

我有一个像这样的字符串:

str = "TO ALL >>> [info][title] Daily report ({{today}})[/title] ■ Today schedule {{task-list}} - {{task}} {{/task-list}} ■ Actual {{task-list}} - {{actual}} {{/task-list}} ■ Reason cannot complete work {{problems}} ■ Next day plan {{next_day_plan}} [/info]"

我想使用正则表达式提取2个标签{{task-list}}和{{/ task-list}}之间的所有内容。我使用此正则表达式:

str.scan /(?<=({{task-list}}))(\D|\d)+?(?=({{\/task-list}}))/

但是结果不会提取2个标签之间的全部内容,而是最后一个字符: [["{{task-list}}", "\n", "{{/task-list}}"], ["{{task-list}}", "\n", "{{/task-list}}"]]

我想念沃特吗?

0 个答案:

没有答案