AVS
AVS

Reputation: 109

Determine if substring corresponds to specific code (character types) in SQL

I have a collection of strings and want to filter out those where the last four characters are: (alpha)(alpha)(number)(number).

I know I can make a substring of each of these and separately, but what is the method to determine the types of the characters in the sequence?

This is for SQL in Hive.

Upvotes: 0

Views: 37

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270873

You can use regular expressions. Something like:

where col regexp '[a-zA-Z]{2}[0-9]{2}$'

Upvotes: 1

Related Questions