- 1

Phone Number Validator Why add “$”?

https://code.sololearn.com/cvy2GaWHcdSP/?ref=app Why does not adding the “$” Regex cause my code to not pass the third case?

5th May 2022, 3:59 AM
aazizul zainal
aazizul zainal - avatar
2 RĂ©ponses
+ 2
"^" and "
quot; acts as anchors. For the beginning or end. Without them, regex match will search the entire string after the matching pattern. So "haha10000000" would be valid.
5th May 2022, 7:30 AM
Mustafa A
Mustafa A - avatar
+ 1
BTW, why the vertical bars in the first part of the pattern? If you need to match a set of chars, put only those chars between brackets. With the bars, it will match 1, |, 8, -| or 9.
5th May 2022, 2:42 PM
Emerson Prado
Emerson Prado - avatar