1

I have the follow text in a document (using Notepad++).

Now, I want to replace all regex occurence with a ?.

I have:

'{$data}', '{$data2}', '{$res}','{$blahblahblah}'

And I want them to become ?,?,?,?

I tried using \b^'{(.+)}'$\b but that doesn't seem to find the pattern.

2
  • You should not use ^ and $ here.. Commented Jun 16, 2015 at 6:19
  • You should use \{\$.+?\} instead. Commented Jun 16, 2015 at 6:19

2 Answers 2

4

You can use the following:

'{\$[^}]+}'

And replace with ?

See DEMO

Explanation:

  • '{\$ match quote, curly brace and $ literls
  • [^}]+} negated character class to match anything other than } more than once (+) followed by }... Equivalent to .*?} but 2-3 times faster
Sign up to request clarification or add additional context in comments.

Comments

2

You need to remove the anchors and word boundaries. And it would be perfect if you escape the braces.

'\{\$.*?\}'

Then replace the match with a ? symbol.

2 Comments

I think the cause of the problem of the OP is also escaping the curly braces, don't you?
Ironically, this was the solution that work for Notepad++.

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.