How does the regex \s* work?
Mahmoud.Sayed7217
Posts: 2 🌱
I was trying to use regex in some Fill In Blank questions. I entered a regex as:
5\s*v?
in order to accept 5 or 5v or 5 v as answers. However, it turns out that it accepts: 3578! it actually accepts anything that has 5 in it. All of the following do the same
\s*
\s?
\s20?
\s*
Which is very strange.
I want to implement "Any number of spaces including 0 spaces". Do you have any idea?
Tagged:
Answers
-
I tried this on regex101.com and it appears to work for what you'd like. (I also accounted for a capital V.)
^5\s*[vV\b]?$
-
Thank you, that actually worked.
I missed the position anchors (^ and $) which caused the problem.