0% found this document useful (0 votes)
8 views2 pages

Oracle Regular Expressions

about Oracle Regular Expressions

Uploaded by

Bharath Krishnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Oracle Regular Expressions

about Oracle Regular Expressions

Uploaded by

Bharath Krishnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Purpose of Regular Expression:

how to check last N position of a column contains alphabet in oracle sql


https://stackoverflow.com/questions/31943096/check-if-last-two-digits-are-
alphabetic

select cmcmatcode,substr(cmcmatcode,-3,3) last3_char,substr(cmcmatcode,-2,2)


last2_char,
substr(cmcmatcode,-1,1) last1_char,REGEXP_SUBSTR((substr(cmcmatcode,-2,2)) , '[A-
Za-z]{1}' ) last1char,
REGEXP_SUBSTR( cmcmatcode ,'([[:alpha:]]{1})$') last1_alpha_char
from matmaster where
REGEXP_LIKE( cmcmatcode ,'([[:alpha:]]{1})$') ;

90040D 40D 0D D D D
90042F 42F 2F F F F
99013C 13C 3C C C C
90043E 43E 3E E E E
90044E 44E 4E E E E
90045D 45D 5D D D D
90046E 46E 6E E E E
90048D 48D 8D D D D
90061C 61C 1C C C C
91006C 06C 6C C C C
91008A 08A 8A A A A
91009A 09A 9A A A A
91010A 10A 0A A A A
91011A 11A 1A A A A
91012A 12A 2A A A A
91014E 14E 4E E E E
91018A 18A 8A A A A
91017E 17E 7E E E E
91029A 29A 9A A A A
91030C 30C 0C C C C
91037C 37C 7C C C C
91039E 39E 9E E E E
91040A 40A 0A A A A
91041A 41A 1A A A A
91042C 42C 2C C C C
91044A 44A 4A A A A
91046E 46E 6E E E E
91045E 45E 5E E E E
91049E 49E 9E E E E
91053A 53A 3A A A A
92003B 03B 3B B B B
92012A 12A 2A A A A
92013B 13B 3B B B B
92016C 16C 6C C C C
99002A 02A 2A A A A
99004A 04A 4A A A A
99008B 08B 8B B B B
99009A 09A 9A A A A
99069A 69A 9A A A A
99115A 15A 5A A A A
99121A 21A 1A A A A
99131A 31A 1A A A A
99180A 80A 0A A A A
99233A 33A 3A A A A
99337A 37A 7A A A A
99363C 63C 3C C C C
99391A 91A 1A A A A
99412A 12A 2A A A A
99459A 59A 9A A A A
99483A 83A 3A A A A
99484A 84A 4A A A A
99504A 04A 4A A A A
99512B 12B 2B B B B
90031L 31L 1L L L L
81325H 25H 5H H H H

https://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/272158.htm
Regular expression feature has been introduced in Oracle Database 10g.

Regular expressions are a method of describing both simple and complex patterns for
searching and manipulating.

RE can be add even on the constraint. if needed,


eg:-
alter table cmcmatmaster_080124_new ADD CHECK
(REGEXP_LIKE(cmcmatcode,'([^[:alpha:]]{1})$'));

This will not allow last postion as Character

To Drop constraint:-
alter table matmaster_080124_new drop constraint SYS_C00184013;

You might also like