Friday, June 17, 2016

How to make first letter uppercase

By using INITCAP function it is possible to make first letter of word UPPERCASE

example


select INITCAP('sample initcap') from dual


result: Sample Initcap

Thursday, May 26, 2016

How to find a word with different endings in the string


SELECT
REGEXP_SUBSTR('I have earned 100 dollars today ','earn((ing)|(ed))')
FROM dual;


result : earned


If you change the string

SELECT
REGEXP_SUBSTR('I have been earning 100 dollars today ','earn((ing)|(ed))')
FROM dual;


result: earning

Wednesday, May 25, 2016

How to add first name first letter to last name name

By using regular expression replace it is possible to add first letter of name to the beginning of the last name.

SELECT LOWER(regexp_replace('Lucky, Edy E', '(.+)(, )([A-Z])(.+)','\3\1', 1, 1))
  FROM DUAL;


Result : elucky

Tuesday, May 24, 2016

How to find alphabetic characters (a-z, A-Z)


By using '[[:alpha:]]' with regular expressions it is possible to find 
alphabetic characters. By adding {3} at the end we limit the length of matching 
alphabetic characters.

Select * from test_table where REGEXP_LIKE(test_column, '[[:alpha:]]');

Select * from test_table where REGEXP_LIKE(test_column, '[[:alpha:]]{3}');

How to find alphanumeric characters (a-z, A-Z, 0-9)

By using '[[:alnum:]]' with regular expressions it is possible to find 
alphanumeric characters.By adding {3} at the end we limit the length of 
matching alphanumeric characters.

Select * from test_table where REGEXP_LIKE(test_column, '[[:alnum:]]');

Select * from test_table where REGEXP_LIKE(test_column, '[[:alnum:]]{3}');
 



Monday, May 23, 2016

How to find repeating substring within string

By using regular expression it is possible to find repeating substring within string

select 
        regexp_replace('telltell','^(.+?)\1*$','\1') sub_str

  from  dual

Wednesday, May 18, 2016

How to find first character of string

By suing SUBSTR  it is possible to find it.

 select SUBSTR ('testing est for test', 1, 1) from dual

resul:t