Python Regex project | SoloLearn: Learn to code for FREE!


Python Regex project

I finished all of the new projects but for whatever reason, I can't pass this single test case (3) from the regex part! I can't even view what the test is because it's hidden. My code for the pattern was '^[189]\d{7}' I tried several other patterns but they all pass 4 other tests except that specific one. Anyone figure it out?

10/14/2020 10:13:47 PM

Python Trader

3 Answers

New Answer


The regex ^[189]\d{7} means that it recognizes any string that contains 8 numbers in the beginning whether or not is followed by other characters. In other words if we have '12345678ddwwaa' is valid the same as '12345678' even though the first one contains non-numeric characters. Therefore it needs to have the character $ at the end of the pattern ^[189]\d{7}$


Regex should end right? Try ending it with $


Worked. Thanks! Didn't realize it was left as an open book. Devil's always in these minutia details.