0

I want to replace statements like these:

identity_LineItemId TEXT(300),
identity_TimeInterval TEXT(300),
bill_InvoiceId TEXT(300),

With these in a large file:

identity_LineItemId=NULLIF(LinkedAccountId, ''),
identity_TimeInterval=NULLIF(LinkedAccountId, ''),
bill_InvoiceId=NULLIF(LinkedAccountId, ''),
bill_BillingEntity=NULLIF(LinkedAccountId, ''),

I tried:

search: .* TEXT(300)

replace with: \1=NULLIF(\1, ''),

But that didn't work.

How can I use a regex replace in notepad++ to replace TEXT(300) with table_name=NULLIF(table_name, ''), ?

1
  • You shouldn't be using regex for such a simple straightforward substitution. But if you'd really like to use regex, you should learn about substitution groups, escaping special characters and character classes at least. I recommend this to do your tests: regexr.com Commented Jul 17, 2019 at 19:15

1 Answer 1

1

You have to capture the first group:

(.*)\sTEXT\(300\)

and replace with whatever you want using \1 to use the first captured group again (everything up to the space)

\1=NULLIF\(LinkedAccountId, ''\)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.