[Answer]-Django sql use regex to check the phone number

1👍

Just replace the - in the number present in the field with empty string and check the resultant string with the original string for equality.

>>> number1 = '0987654321'
>>> s = '0987-654-321'
>>> if s.replace('-', '') == number1:
        print("equal")
    else:
        print('Not equal')


    equal

Leave a comment