views:

125

answers:

2

I am using the REGEXP_LIKE function in Oracle 10g to find values in a column with a suffix of _#(like _1, _2 etc). I can find _# in any part of the value with the query below but can I return only values with _# at the end ?

SELECT * FROM Table WHERE  REGEXP_LIKE (COLUMN,'_[[:digit:]]')
+8  A: 

Sure. Use...

SELECT * FROM Table WHERE  REGEXP_LIKE (COLUMN,'_[[:digit:]]$')

The $ character matches "the end of the string."

VoteyDisciple
THANKS !! I though I was going to have to spend some quality time with my "Mastering Regular Expressions" book. Still on the to-do list but for another day.
caddis
You really really really ought to read that book. Understanding regex is a major contribution to coder productivity.
APC
+1  A: 

No need to use reg exps.

select * from table where substr(column,-2) between '_0' and '_9';
tuinstoel
Very cool response thank you for posting it.
caddis