Via Lattanzio,23 Milano
+39 02 36592025
info@synaptica.info

Firebird SQL – Verify if a string contains digit (number char)

Digital solution partner

Firebird SQL – Verify if a string contains digit (number char)

From version 2.5 Firebird introduces the “SIMILAR TO” predicate which allows you to apply a subset of regular expressions in an SQL condition.

The documentation of the “SIMILAR TO” predicate is available at https://firebirdsql.org/refdocs/langrefupd25-similar-to.html

If we wanted to check if there are numbers (DIGIT) inside a string, i.e. characters from ‘0’ to ‘9’ we could simply write:

in this case the expression

‘AG8G9SG’ SIMILAR TO ‘% [[: DIGIT:]] {1}%’ -> True

‘Giorgio’ SIMILAR TO ‘% [[: DIGIT:]] {1}%’ -> False

I hope it was useful …