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 match the specified substring
SELECT empName, REGEXP_SUBSTR(emailID, '[[:alnum:]]+\@[[:alnum:]]+\.[[:alnum:]]+') "Valid Email" FROM regexp_temp
EMPNAME | Valid Email | John Doe | johndoe@example.com | Jane Doe | - |
---|
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 the table
DROP TABLE regexp_temp
Table dropped.