0

In my XML file there are lots of sub strings starting with STDSUP- and then three digits. For example: STDSUP-123. I would like to replace the STDSUP with CCDA. There are some sub strings where STUSUP- is following by non-numeric characters. I don't want to change them. So, I used STDSUP-\d\d\d in the find field and CCDA-\d\d\d in the replace with field. But the three digits are getting replaces with ddd. I want to replace only STDSUP and want the digits unchanged.

Any help?

1

To keep part of the string intact, you want to use a group in your "find" expression and a backreference in your "replace" one.

Find: STDSUP-(\d\d\d)
Replace: CCDA-\1

screencap

1

Starting in Notepad++ version 6, you can also separate the match with PCRE-style capture groups:

Find What: (STDSUP-)(\d\d\d)

Replace with: CCDA-$2

  • -1: This does not work in Notepad++ - it replaces the digit string the OP wanted to preserve with $2. See this screencap. – nc4pk Jul 22 '13 at 19:05
  • 1
    It works in Notepad++ starting in version 6. see: stackoverflow.com/a/11970406/1521193 – kjh23 Jul 22 '13 at 19:12
  • Ah, my bad. I was still running the old version. Edited and undownvoted :) – nc4pk Jul 22 '13 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.