2017-12-27 218 views
-2
var str1 = "hello <span contenteditable="false" class="underlineText hashtags hello">hello<span style="display:none;"> [#[#hello]#] [#[#hi]#] [#[#welcome]#]</span></span>" 

var arr = textToPost.match(/#^[a-zA-Z0-9]/g) 

我想提取與此模式[#[#*]#]匹配的字符串。正則表達式模式[#[#hello]#]在javascript中匹配

+0

所以,要提取'hello','hi'和'welcome' - 是正確的? – vlaz

回答

0

試試這個正則表達式,它與我的作品

var reg = /\[[#[a-zA-Z0-9]+]#]/ig; 

var str1 = "hello hello [#[#hello]#] [#[#hi]#] [#[#welcome]#]"; 
 
var reg = /\[[#[a-zA-Z0-9]+]#]/ig; 
 
var arr = str1.match(reg); 
 
console.log(arr)

+0

工作很好,非常感謝你:)。你讓我的一天變得輕鬆 –

+0

如果你覺得它有幫助,歡迎你來投票 –