Saturday 18 November 2017

Remove all or some special characters from a string using regular expressions

Source:

CREATE TABLE FILENAM(FILENAME VARCHAR2(200));
INSERT INTO FILENAM VALUES('FILE1/\:');
INSERT INTO FILENAM VALUES('FILE1/?<');
INSERT INTO FILENAM VALUES('FILE1/?>');
INSERT INTO FILENAM VALUES('FILE1/?|');
INSERT INTO FILENAM VALUES('FILE1/?=<');
INSERT INTO FILENAM VALUES('FILE1/?<,');
INSERT INTO FILENAM VALUES('FILE1/?<*');
INSERT INTO FILENAM VALUES('FILE1/\:*?<>|=,');
INSERT INTO FILENAM VALUES('FILE1/\:*?<>|$=,');
COMMIT;


Query:



Output:


Tuesday 25 July 2017

Identifying all the domains in the data

Input:




Output:




Identify the domain in the email id



Usually we know how to use SUBSTRING and INSTRING functions to extract a portion of a string passing the positions of a character.

Here we have a scenario , step ahead of normal scenario.

The username itself contains @symbols.It's just an assumption.




Tuesday 31 January 2017

Split the comma separated values of a single column into multiple rows


I have a column and value is 1,2,3,4,5,6. Need to split this value into rows.

Note: 1,2,3,4,5,6 is a single value under column.





Friday 20 January 2017

Find all the positions of an occurrence of a character in a string



I have an SSN# with format 123-45-6789. Here the character '-' is repeated in 4th and 7th position of a string. I need to write an SQL query to find out the positions of that characters.