or
SELECT REGEXP_SUBSTR('2009-452XAB
Main Topics
Browse All TopicsI am executing the following:
SELECT REGEXP_SUBSTR('2009-452XAB
My expected resut is XAB
I have tried moving the splat (*) around without any success. I have tried using the other parameters of the function as well.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Ah ha. Thank you very much.
Help me out a little further. I do not understand why a 0-n operator (*) would not return a value when a + 1-n operator (+) does.
And a general question ... I find regex to be totally frustrating. On the one hand it seems to solve an entire class of problems. On the other hand, it seems to be very flakey - I have used it in POSTGRES and now in ORACLE and both implementations seem difficult to master. Is REGEX really reliable or are the rules so complicated to effect in the underlying implementation that it will remain forever somewhat unreliable?
>>I do not understand why a 0-n operator (*) would not return a value when a + 1-n operator (+) does.
This is part of the learning curve of regexes, and most moderately seasoned programmers still don't understand it.
Regexes are greedy, but they also will try to match the whole pattern as soon as possible. So when we say greedy, we mean that once a rule is able to be matched, the engine will consume as much of the input text that matches the current state, then move on to the next state, if possible. If not, it will backtrack. So if you look at your example, 0-n legally can be satisfied with the empty string. That is the first state in your rule, and the only state.
Perhaps an example is easier, try both of these:
SELECT REGEXP_SUBSTR('123XYZ','[[
SELECT REGEXP_SUBSTR('ABC123XYZ',
In the first one, where do you think the [[:alpha:]]* state was satisfied?
>>On the other hand, it seems to be very flakey - I have used it in POSTGRES and now in ORACLE and both implementations seem difficult to master. Is REGEX really reliable or are the rules so complicated to effect in the underlying implementation that it will remain forever somewhat unreliable?
Regex engines are Finite State Automata. This, by definition, is the opposite of flaky.
Now, as to different implementations, yes, some regex engines have quirks, but most use the Perl5 "flavor" nowadays so if you learn that, as well as the POSIX character classes (the ones surrounded by colons, like :alpha:) then you can take that anywhere you go.
Business Accounts
Answer for Membership
by: mrjoltcolaPosted on 2009-10-22 at 07:11:17ID: 25634393
SELECT REGEXP_SUBSTR('2009-452XAB ','[a-zA-Z ]+') FROM DUAL;