Regular expression that allows spaces in a string, but not only blank spaces

后端 未结 6 2109
长发绾君心
长发绾君心 2020-12-01 18:31

I need to write a regular expression for form validation that allows spaces within a string, but doesn\'t allow only white space.

For example - \'Chicago Heigh

6条回答
  •  难免孤独
    2020-12-01 18:58

    Try this regular expression:

    ^[^\s]+(\s.*)?$
    

    It means one or more characters that are not space, then, optionally, a space followed by anything.

提交回复
热议问题