我有一个看起来像这样的正则表达式:
[@|#](.*?)\s
我基本上想要的是,将匹配的正则表达式拆分为数组。
所以我使用以下代码:
var testString = "Hi this is a test @info@test.com and @martin we have to go." console.log(testString.split(/(\@|\#)(.*?)\s/));
我得到的结果是这样的:
["Hi this is a test ", "@", "info@test.com", "and ", "@", "martin", "we have to go."]
我真正想要的是:
["Hi this is a test ", "@info@test.com", "and ", "@martin", "we have to go."]
https://regex101.com/r/yJf9gU/1
https://jsfiddle.net/xy4bgtmn/
慕少森
慕哥9229398
相关分类