0% found this document useful (0 votes)
977 views1 page

SSN Validation Using SQL Regex

This document discusses validating Social Security Numbers and phone numbers using regular expressions in Oracle. It shows an example of using a regular expression to check if a sample SSN matches the proper format of three digits, two digits, and four digits separated by hyphens. The regular expression could also be customized slightly to validate phone numbers with the same general approach.

Uploaded by

Sp Vinoth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
977 views1 page

SSN Validation Using SQL Regex

This document discusses validating Social Security Numbers and phone numbers using regular expressions in Oracle. It shows an example of using a regular expression to check if a sample SSN matches the proper format of three digits, two digits, and four digits separated by hyphens. The regular expression could also be customized slightly to validate phone numbers with the same general approach.

Uploaded by

Sp Vinoth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Validate SSN

select case when regexp_like('987-65-4321' ,'^[0-9]{3}-[0-9]{2}-[0-9]{4}$') then


'Match Found' else 'No Match Found' end as output from dual;
Output: Match Found
Input: 987-654-3210
Output: No match found
^ start of the string
[0-9]{3} three occurrences of digits from 0-9
- followed by hyphen
[0-9]{2} two occurrences of digits from 0-9
- followed by hyphen
[0-9]{4} four occurrences of digits from 0-9
$ end of the string
The above pattern can also be used to validate phone numbers with little
customization.

You might also like