Link to home
Start Free TrialLog in
Avatar of mohammadzahid
mohammadzahidFlag for Canada

asked on

Oracle regular expression

Using Oracl regular expressions I want to extract character after the \

'OPS$BCTGTWDOM\SMANAVI'     Output => SMANAVI

How can I do this?

Thanks
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

You can do it with regular expressions but those are expensive calls.

I would use SUBSTR and INSTR.  It will likely be faster:
select substr('OPS$BCTGTWDOM\SMANAVI',instr('OPS$BCTGTWDOM\SMANAVI','\')+1) from dual;

that was hard-coded.  I assume you have it in a table?
select substr(yourcolumn,instr(yourcolumn,'\')+1) from yourtable;
Someone will post it so here is the regexp_substr:
select regexp_substr('OPS$BCTGTWDOM\SMANAVI','[^\]+$') from dual;
why use regexp where INSTR and SUBSTR will do this as well (and more efficiently)?
if you only need to identify the backslash and then clip out the text which follows it, regexp is a sledgehammer to crack a nut.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.