^a-zA-Z0-9 excluding spaces?

前端 未结 4 1781
遇见更好的自我
遇见更好的自我 2021-02-08 04:50

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

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


        
相关标签:
4条回答
  • 2021-02-08 05:27

    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]", "")
    
    0 讨论(0)
  • 2021-02-08 05:36

    You could also try with:

    /[^a-zA-Z0-9\s]/gi
    
    0 讨论(0)
  • 2021-02-08 05:36

    If you only want to exclude spaces use:

    [^ ]*
    

    Test the regex here if you want.

    0 讨论(0)
  • 2021-02-08 05:44

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

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

    0 讨论(0)
提交回复
热议问题