Quantcast
OracleBrains.Com header image 2

Working Example of REGEXP_LIKE -2

September 23rd, 2007 by Rajender Singh · No Comments

Scenario From Oracle Forum

This function seems like a good idea for password validation, for example one number and 4-8 characters.

However, this does not work - any ideas?

select
1 from dual where
regexp_like(upper(’PA55WORD’),’^(?=.*\d).{4,8}$’)

Solution which I gave:

WITH data_Set AS
(
SELECT 1 row_no, ‘3434HERE’ text_col FROM dual
UNION ALL
SELECT 2 row_no, ‘EYRERY787′ text_col FROM dual
UNION ALL
SELECT 3 row_no, ‘DHFD67SDSD’ text_col FROM dual
UNION ALL
SELECT 4 row_no, ‘ERERT’ text_col FROM dual
UNION ALL
SELECT 4 row_no, ‘23232′ text_col FROM dual
)
SELECT row_no FROM data_set
WHERE REGEXP_LIKE(UPPER(text_col),’([[:alpha:]]+[[:digit:]]+[[:alpha:]]+)|([[:digit:]]+[[:alpha:]]+)|([[:alpha:]]+[[:digit:]]+)’)
/

Result as follows:
ROW_NO
———-
1
2
3


Tags: Interesting Coding Showcase · SQL and PL/SQL

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comment moderation is enabled. Your comment may take some time to appear.