^a-zA-Z0-9 excluding spaces?

爱⌒轻易说出口 提交于 2019-12-04 11:18:40

问题


I am trying to find everything in a paragraph that is not abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 and not space / /gi

/[^a-zA-Z0-9]|[^ ]/gi

the above doesn't work!


回答1:


You could also try with:

/[^a-zA-Z0-9\s]/gi



回答2:


If you only want to exclude spaces use:

[^ ]*

Test the regex here if you want.




回答3:


try ^[\d\w]*$ or ^[\w]*$ as reg' Expression means from ^(start) to $(end) match 0-9a-zA-Z only

for c++ ansistring="^[\\d\\w]*$";




回答4:


You can use this for am trying to find everything in a paragraph that is not abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 and not space / /gi

replaceAll("[^A-Za-z0-9\\s]", "")


来源:https://stackoverflow.com/questions/9626283/a-za-z0-9-excluding-spaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!