RegEx: Character Classes XI ⁠- \S

Published by Isaac Pak in

You can think of character classes as characters with special meaning. They are recognized as special when you place the \ before the character.

Here are a list of the characters classes in JavaScript:

., \cX, \d, \D, \f, \n, \r, \s, \S, \t, \v, \w, \W, \0, \xhh, \uhhhh, \uhhhhh, [\b]

Write a regex that will return true if the bio does not have any spaces before the last ending punctuation ?. You must use the \S character class in your expression.

"Can read a spray chart and a balance sheet. 1 part Executive, 1 part entrepreneur, 2 parts geek and 3 parts baseball coach. Too many parts?"

The bio above is in the correct format. Therefore your RegEx should return true for it.

Notes

  • Check the Resources tab for details on character classes if you're stuck.
  • Mark Gallion's Twitter bio is used for educational purposes only.
  • To search for the character ? in RegEx, the pattern must include \?.
Watch a quick demo on how Edabit works.