【发布时间】:2014-03-19 20:34:34
【问题描述】:
我正在尝试解析短代码:
[shortcode]the content inside[/shortcode]
这很好用,因为它都是一行,但是一旦我有多行,我就无法捕获该组:
[shortcode]
this is
the content
[/shortcode]
我当前匹配内联文本的表达式是:\[([^\]]*?)\](.*)\[\/\1\]
我无法修改(.*) 部分以捕获包括新行在内的所有内容。
这是要在javascript中使用的,所以我不能使用/s修饰符。
可以在这里看到一个例子:http://regex101.com/r/nZ1hZ4
【问题讨论】:
-
[\w\W] 在 JS 中很漂亮
标签: javascript regex