例如我有这个字符串:

#fox #fo x #fox # fox # fox

我怎样才能得到这样的字符串:

fox fox fox fox fox

我无法正确删除多余的空格

UPD:因为当我删除'#'时,我得到空白空间,例如fox fox

最佳答案

您可以通过以下方式选择哈希之前的所有空格:

\s(?!#)


Regex live here.

如果您还想匹配哈希值:

\s(?!#)|#


Regex live here.

关于javascript - 如何使用正则表达式解析标签?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33336838/

10-09 09:23