Parentheses clinging to my backreference

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
ionFreeman
Posts: 6
Joined: Fri Mar 03, 2006 3:19 pm

Parentheses clinging to my backreference

Post 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!
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Use Posix regular expression syntax:
Configuration | Preferences | Editor

[X] Use POSIX regular expression syntax
This swaps the meanings of (...) and \(...\).
ionFreeman
Posts: 6
Joined: Fri Mar 03, 2006 3:19 pm

Oh, I see

Post 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!
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do use Posix syntax, and not the default. You know it makes sense!
Post Reply