Create a new table regexp_temp
CREATE TABLE regexp_temp(empName varchar2(20), emailID varchar2(20))
Table created.
Inserting rows into the regexp_temp table
INSERT INTO regexp_temp (empName, emailID) VALUES ('John Doe', 'johndoe@example.com')
1 row(s) inserted.
Inserting rows into the regexp_temp table
INSERT INTO regexp_temp (empName, emailID) VALUES ('Jane Doe', 'janedoe')
1 row(s) inserted.
Query the table columns and check the specified string is contained in the column value
SELECT emailID, REGEXP_INSTR(emailID, '\w+@\w+(\.\w+)+') "IS_A_VALID_EMAIL" FROM regexp_temp
EMAILID | IS_A_VALID_EMAIL | johndoe@example.com | 1 | janedoe | 0 |
---|
Combined Substring and Instring example
SELECT empName, REGEXP_SUBSTR(emailID, '[[:alnum:]]+\@[[:alnum:]]+\.[[:alnum:]]+') "Valid Email", REGEXP_INSTR(emailID, '\w+@\w+(\.\w+)+') "FIELD_WITH_VALID_EMAIL" FROM regexp_temp
EMPNAME | Valid Email | FIELD_WITH_VALID_EMAIL | John Doe | johndoe@example.com | 1 | Jane Doe | - | 0 |
---|
DROP TABLE regexp_temp
Table dropped.