on ‎2018 Sep 18 7:56 AM
When using groups within a regex, it is usually possible to "back reference" to such a group via its number (or name), such as "\\1" to reference to the first (capturing) group.
Am I right that this is not supported with SQL Anywhere?
Here's a sample:
-- search for a number followed by non-digits and a further number
select regexp_substr('abc-101-abd-102-abe', '(\\\\d+)\\\\D+\\\\d+');
-- -> returns "101-abd-102"
-- If I want the match to restrict to those cases
-- where the first and second number are identical,
-- that requires a backreference via \\1, such as
select regexp_substr('abc-101-abd-102-abe', '(\\\\d+)\\\\D+\\\\1'); -- should not match
select regexp_substr('abc-101-abd-101-abe', '(\\\\d+)\\\\D+\\\\1'); -- should match
However, adding '\\\\1' to the regexp pattern leads to SQLCODE -1135 aka "Invalid regular expression: unsupported syntax in '(\\d+)\\D+\\1'"
I'm using 16.0.0.2704 but I guess the regex support has been unchanged for quite a number of versions.
Request clarification before answering.
Hi Volker,
SQL Anywhere does NOT support back references in regular expressions.
See https://help.sap.com/viewer/40c01c3500744c85a02db71276495de5/17.0/en-US/81735cab6ce21014b8a287b4fbb8... for the list of escaped characters supported, and note that back references are not listed.
Ian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.