I'm trying to make a RegEx that matches all thematic breaks in a string for use in JavaScript's String.split function.
A thematic break can be:
- Hyphens:
--- - Asterisks:
*** - Underscores:
___
Can have whitespace between the hyphens, asterisks or underscores, but you can't mix-n-match, for example this is not valid --*.
Full spec: https://spec.commonmark.org/0.30/#thematic-breaks
Here's what I've tried: /[-*_]{3,}/g but that does not match ones with whitespace in the middle, if I add a space there it will match stuff like -- which is not desirable. I also thought of first striping the whitespace but I'd like to fit it all into a RegEx.
Is this possible? And how?