簡體   English   中英

Javascript RegEx:提取順序數組中的單詞和分隔符

[英]Javascript RegEx: extract words and separators in sequential array

如何在JavaScript中解析字符串並僅提取單詞,但如何將結果數組保留分隔單詞的其他文本部分。

"  This is - a string.  With two  and one spaces!"

至:

['  ', 'This', ' - ', 'a', ' ', 'string', '.  ', 'With']

你可以寫:

var resultArray = origString.split(/\b/);

鏈接:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM