Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Best way to find string composed of dup character?
I need to be able to determine whether a varchar2 column contains a
string of dup characters. Specifically, I need to weed out (or
alternatively find) phone numbers like: 1111111, 9999999999, etc.
Here is what I came up with for use in a where predicate:
...
substr(p1.phone_number,-(least(7,length(p1.phone_number)))) !=
rpad(substr(p1.phone_number,-1,1),least(7,length(p1.phone_number)),
substr(p1.phone_number,-1,1))
Obviousely "P1" is the phone_number table. I used LEAST to check up to seven digits- not sure if that's helpng or hurting though.
Any comments?
TIA
Received on Wed Feb 25 2004 - 08:01:29 CST
![]() |
![]() |