我有当前的正则表达式:
/(?<=[\s>]|^)#(\w*[A-Za-z_]+\w*)/g
我在对比这个字符串进行测试:
Here's a #hashtag and here is #not_a_tag; which should be different. Also testing: Mid#hash. #123 #!@£ and <p>#hash</p>
为了我的目的,这个字符串中只应该检测到两个哈希标记。我想知道如何修改表达式,使其不匹配以分号结尾的哈希标记,在我的示例中是 #not_a_tag;。谢谢。
\B
吗?在#
前需要有实际字符才能使用\W
。 - Tim Pietzcker