【发布时间】:2018-08-21 21:29:33
【问题描述】:
我有这个:
const str = "hello **Tom**, it's currently **19h25**. Here is **19** things found during the **last 2 hours** by **John1**"
我需要在内容中有数字的地方找到所有出现的被双星号包围的内容。
我希望str.match(regex) 返回['19h25', '19', 'last 2 hours', 'john1']。但不是**Tom**,因为内容中没有数字。
我尝试过像 /\*{2}(.*\d)\*{2}/g 这样的正则表达式,但它不起作用。
编辑:* 内部没有星号 **
【问题讨论】:
-
**和**里面可以有*吗?如果没有,请使用/\*{2}([^\d*]*\d[^*]*)\*{2}/g
标签: javascript regex match