1

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 []) ?

Mossos
  • 11
  • 1
  • 4
  • Generally, you don't have to escape things within classes. (And you may want to put the `-` last in the class, so as not to make a range between `/` and `+`.) – Biffen Mar 20 '14 at 11:19
  • It doesn't work neither: Invalid regular expression: unexpected metacharacter in '[0-9/+-]*' – Mossos Mar 27 '14 at 15:29

1 Answers1

0

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/-\+]*'
Mossos
  • 11
  • 1
  • 4