I am working on Oracle 10gR2.
I am working on a column which stores username. Let's say that one of the values in this column is "Ankur". I want to fetch all records where username is a concatenated string of "Ankur" followed by some numerical digits, like "Ankur1", "Ankur2", "Ankur345" and so on. I do not want to get records with values such as "Ankurab1" - that is anything which is concatenation of some characters to my input string.
I tried to use REGEX functions to achieve the desired result, but am not able to.
I was trying:
SELECT 1 FROM dual WHERE regexp_like ('Ankur123', '^Ankur[:digit:]$');
Can anyone help me here?
Oracle uses POSIX EREs (which don't support the common \d shorthand), so you can use
^Ankur[0-9]+$
Your version would nearly have worked, too:
^Ankur[[:digit:]]+$
One set of [...] for the character class, and one for the [:digit:] subset. And of course a + to allow more than just one digit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With