We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Validating Postal Codes
Validating Postal Codes
Sort by
recency
|
320 Discussions
|
Please Login in order to post a comment
My second hard problem <3.
LookAround operator are mandatory when we want to know the number of occurences. This is what we have to learn from this exercise, and also the back reference operators.
Fortunately, the exercise with credit card, and valid UID train us for that. So it was fluid to continue with this problem.
Here is HackerRank Validating Postal Codes in Python solution - https://programmingoneonone.com/hackerrank-validating-postal-codes-solution-in-python.html
I did it the dumb way but it works:
regex_integer_in_range = r"^[1-9][0-9]{5}$" regex_alternating_repetitive_digit_pair = r"(?=(0.0|1.1|2.2|3.3|4.4|5.5|6.6|7.7|8.8|9.9))"