There is a regular code: /^[^.][\w\s-.\,!\?()]+[^.]/iu , but this code does not read characters such as: 0\/|=+@$#%^&*"â„–;:?'<> , How to make him start reading them?

  • \s-. it looks very strange, because \ s means any whitespace character, and not the space itself, and using it as the beginning of the interval is unpredictable, it’s better to use the space itself. And the interval is 'space-.' in theory should give a lot of characters, but not all. Look at the asciitable.com ASCII table to set the correct intervals or list the characters one by one - Mike
  • Maybe it is worth starting from a set of characters that should not be included in a character class? - Dmitriy Simushev
  • Well, you can, but the whole point is that I have no idea how to remove spaces in the text, namely, if the text is transmitted empty (That is, just clicked the send button, put spaces, or used the alt + 0160 command and .n, but not the text itself) If there is such a regular at all, which checks such, I would be grateful if you give. - in1
  • @in1, so what exactly do you need? to remove all spaces from a string? so your regular expression does not perform any substitutions, only matching the pattern. i.e., the result is not the string “without spaces”, but “yes” or “no”. - aleksandr barakin
  • I need it, for example, the user sends a message, empty, with spaces - the message is checked by a regular schedule, if everything is good, then it sends a message, if not - then an error. - in1

0