Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Find '[' and get sub-string before it by using regexp_substr()

843098Feb 26 2011 — edited Mar 1 2011
Hi,

select regexp_substr('What a good day for (YOU [ME] and HIM','[:ALNUM:]*[^\(]*') from dual;
result is:
SQL> What a good day for

but why this pattern does not work for ']' when I replace '(' with ']'?
select regexp_substr('What a good day for (YOU [ME] and HIM','[:ALNUM:]*[^\]]*') from dual;
result is:
SQL> W

I need to get a sub-string before either '(', '[', '{' , ')', ']', or '}' in a give string, this pattern works for '(', ')', '{', '}' but not '[' or ']'
what should the pattern be? If '[:ALNUM:]*[^\(]*' is not correct?

Can anyone help?

thanks
Fiona
This post has been answered by Frank Kulash on Mar 1 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 29 2011
Added on Feb 26 2011
6 comments
1,688 views