Skip to main content
Hello All, I want to check of the fourth character in a phone number and make sure it's / and also make sure the 8 character is a dash - How would I do that? Example 314/789-9696

Hello,

 

I assume you want to check it with PQL in frontend and you need to have both to mark number as a valid? I would use Case statement with SUBSTRING functions. Mark as best answer if that helped you :)

 

Usually for for more complicated cases where it would be much more complex (for example multiple characters would be allowed instead of / and - in those places) I would recommend using regex (usable in ML workbench by using python packages, or in data integration by using SQL Vertica

 

PQL regular code:

CASE WHEN

 SUBSTRING ( '${telephone_number}', 3, 1 ) = '/'

 AND SUBSTRING ( '${telephone_number}', 7, 1 ) = '-'

THEN

 'Its ok!'

ELSE

 'Not ok!'

END

 

Case 1:

image 

Case 2:

image 

Best Regards,

Mateusz Dudek


Reply