Search Postgresql Archives

repeated characters in SQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a simple table consisting of a bunch of English words.  I am trying to find words that have repeated characters in them, for example
apple
tattoo

but not

orange 
lemon

I know that only a maximum of one repetition can occur

I tried various options like
SELECT word FROM  public."SpellItWords" 
 WHERE word ~ E'(.)\1{2,}'

SELECT word FROM  public."SpellItWords" 
 WHERE word ~ E'([a-z])\1{2}'

What finally worked was this
SELECT word FROM  public."SpellItWords" 
 WHERE word ~ E'(.)\\1'

But I don't really understand what this does...Can you explain?

Thanks!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux