tags:

views:

115

answers:

2

I want to find all the names that start with numbers, weird chars (.,-#$, etc) and everything else that isn't a letter.

For example, i have 3 names: John, #1 John and 2John. What I want to get is the last 2 names. (and I don't know what weird chars the names can start, so it must be something like ![a-Z])..

I'm using postgresql.

+2  A: 

PostgreSQL Manual: Pattern Matching

Dutow
+4  A: 
SELECT  *
FROM    Table
WHERE   name ~ '^[^a-zA-Z]'

If accented or non-Latin characters don't fall under your definition of "weird stuff", you may use:

SELECT  *
FROM    Table
WHERE   name ~ '^[^[:alpha:]]'
Quassnoi