Reputation: 37
I'm new to regexes and I'm trying to find a regex that matches :randomNumberOfWhitespacesOrNothing:
I've tried something like this :([\s\S]*):
but it didn't work. Can anyone help me?
Upvotes: 1
Views: 39
Reputation: 626689
The \S
pattern matches any non-whitespace symbol. Remove it from your character class and use
:(\s*):
See the regex demo
Details:
:
- a colon(\s*)
- capturing group with ID 1 that matches 0+ (due to *
quantifier) whitespace symbols:
- a colon.Upvotes: 1