Page 1 of 1

Parentheses clinging to my backreference

Posted: Fri Mar 03, 2006 3:32 pm
by ionFreeman
I'm converting Oracle code to SQL Server. One of my little tricks is to run regexp replaces like
TO_CHAR\((.*)\)
with
CAST(\1 AS NVARCHAR(8))
but this give me
CAST((numstring) AS NVARCHAR(8))
instead of
CAST(numstring AS NVARCHAR(8))
Apparently, the parentheses I'm using to denote the token I'm looking for become real parentheses.
Is this a bug, or am I making an error? It works fine, but there may be cases in which this bites me, so I'd like to clear it up.
Thanks! I look forward to the new RegExp forum. And news on new versions!

Posted: Fri Mar 03, 2006 4:40 pm
by ben_josephs
Use Posix regular expression syntax:
Configuration | Preferences | Editor

[X] Use POSIX regular expression syntax
This swaps the meanings of (...) and \(...\).

Oh, I see

Posted: Fri Mar 03, 2006 4:59 pm
by ionFreeman
Now that you mention it, I did notice that the examples used escaped parens to bracket a search token. I just didn't internalize it.
Thanks!

Posted: Fri Mar 03, 2006 5:02 pm
by ben_josephs
Do use Posix syntax, and not the default. You know it makes sense!