Home > Blockchain >  Regular expression not working Sybase ASE 16.0
Regular expression not working Sybase ASE 16.0

Time:05-15

I am trying to retrieve IDs from a table in Sybase ASE 16.0

The query has to return IDs starting with AB or BC. Example AB0001 AB0002 BC0001 BC0002

The regular expression in my query is not working

Select * from T1 where id like '(AB|BC)%'

The above query is not working. Can someone suggest the correct regex statement that works in ASE.

CodePudding user response:

ASE 16 doesn't support this kind of regex like. Please try below SQL:

select * from T1 where id like 'AB%' or col2 like 'BC%'

CodePudding user response:

To my knowledge, no SQL LIKE operator supports regex alternations. But we can use the REGEXP operator:

SELECT * FROM T1 WHERE id REGEXP '^(AB|BC)';
  • Related