Thursday 4 January 2007

Regular Expressions to Show the First Occurance of n Upper Case Characters

I must admit, I still can't feel comfortable with regular expressions, but here is a neat one:

SELECT (REGEXP_SUBSTR('AbcDERTK1DEcdhfjUWXvbDERTF' , '[[:upper:]]{5,}'))
FROM dual

It selects the first sequence of characters which has 5 upper cases together.
So the result is: DERTK

or

SELECT (REGEXP_SUBSTR('AbcDEcdhfjUWXvbDERTF' , '[[:upper:]]{3,}'))
FROM dual

is : UWX

No comments: