Regex - Combining positive and negative lookbehind
Asked Answered
H

1

11

I am doing some replaces in some huge SSIS packages to reflect changes in table- and column names.

Some of the tabels have columnnames witch are identical to the tablenames and I need to match the columnname without matching the tablename.

So what i need is a way to match MyName in [MyName] but not in [dbo].[MyName]

(?<=\[)(MyName)(?=\]) matches both, and I thought that (?<!\[dbo\]\.)(?<=\[)(MyName)(?=\]) would do the trick, but it does not seem to work.

Hammad answered 26/10, 2010 at 9:19 Comment(0)
I
9

You need to include the opening square bracket in the first lookbehind:

(?<!\[dbo\]\.\[)(?<=\[)(MyName)(?=\])
Inimical answered 26/10, 2010 at 9:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.