Quick Search:
 Oracle PL/SQL: Regular Expressions: RegExp examples three Jump to:  
Category: >> Oracle PL/SQL >> Regular Expressions: RegExp examples three  

<< lastnext >>

Snippet Name: Regular Expressions: RegExp examples three

Description: Patterns for matching Social Security Numbers, US phone numbers, US ZIP codes, and IP addresses.

Also see:
» Regular Expressions: REGEXP_SUBSTR
» Regular Expressions: REGEXP_LIKE
» Regular Expressions: REGEXP_REPLACE
» Regular Expressions: RegExp examples t...
» Regular Expressions: RegExp examples o...
» Regular Expressions: Regexp Cheat Sheet
» RegExp: Append first name first letter...

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 12th, 2009

-- search for Social Security Numbers (xxx-xx-xxxx)
FROM sandbox
WHERE REGEXP_LIKE(regex_test,'^[0-9]{3}-[0-9]{2}-[0-9]{4}$');
-- match US phone number with or without parentheses
FROM sandbox
WHERE REGEXP_LIKE(regex_test,'^\([0-9]{3}\)[:space:]?[0-9]{3}(-|[:space:])?[0-9]{4}$|^[0-9]{3}-?[0-9]{3}-?[0-9]{4}$');
-- match US ZIP codes 
FROM sandbox
WHERE REGEXP_LIKE(regex_test,'[0-9]{5}(?-[0-9]{4})?');
-- handy pattern for matching an IP address:

   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org