Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the regex \S mean in JavaScript? [duplicate]

People also ask

What does \s match regex?

\s stands for “whitespace character”. Again, which characters this actually includes, depends on the regex flavor. In all flavors discussed in this tutorial, it includes [ \t\r\n\f]. That is: \s matches a space, a tab, a carriage return, a line feed, or a form feed.

What is \s in regex JavaScript?

The \s metacharacter matches whitespace character. Whitespace characters can be: A space character.

What does \\ s+ mean in Java?

The Java regex pattern \\s+ is used to match multiple whitespace characters when applying a regex search to your specified value. The pattern is a modified version of \\s which is used to match a single whitespace character.

What does \+ mean in regex?

Example: The regex "aa\n" tries to match two consecutive "a"s at the end of a line, inclusive the newline character itself. Example: "a\+" matches "a+" and not a series of one or "a"s. ^ the caret is the anchor for the start of the string, or the negation symbol.


\s matches whitespace (spaces, tabs and new lines). \S is negated \s.


\S matches anything but a whitespace, according to this reference.


I believe it means 'anything but a whitespace character'.


/\S/.test(string) returns true if and only if there's a non-space character in string. Tab and newline count as spaces.