Reputation: 197
I want to write a regex that matches string that has both numeric and alphabets. ^[a-zA-Z0-9]*$
-- this pattern returns numeric as well as alphabets, but I want only alphanumeric. Basically I'm using postgresql to query rows that contain numericals in it.
Upvotes: 4
Views: 12528
Reputation: 1269873
I think multiple regex's is the easiest way:
where col ~ '^[a-zA-Z0-9]*' and
col ~ '[0-9]' and
col ~ '[a-zA-Z]'
There is probably a complicated regexp that combines this all together, but this seems like the most intuitive method.
Upvotes: 7