Pergunta

I'm using Sybase SQL (ASA) and currenty I'm working with regular expressions.

My task is to check strings if they only contains numbers, '+','-' or '/' like following string: '+49176/3421094'

My statement looks something like that (just a test):

Select * from (select '+49176/3421094' Tele from dummy) a
where Tele SIMILAR TO '[0-9/-\+]*'

In the documentation it says that metacharacters have to be escaped with '\' but if I execute this statement an sql error is thrown with the message "unknown metacharacter".

My question is: How do I have to escape metacharacters (espacially in classes []) ?

Foi útil?

Solução

I solved my problem by using "REGEXP" instead of "SIMILAR TO":

Select * from (select '+49176/3421094' Tele from dummy) a
where Tele REGEXP '[0-9/-\+]*'
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top