3

I know this might have been asked before, but I could not find an answer to it.

I need to replace the following: CoverLevel="XX" with CoverLevel="0" , this includes XX being any number, without replacing the similar instances such as CoverLevel="True" or CoverLevel or MinCoverLevel="1.3"

would that be possible with notepad++ ?

9

At the bottom of the search/replace window you can select the search mode "regular expression", then you can search for

CoverLevel="\d\d"

the \d means any number, in a regular expression. This searches for two numbers, if you want to search for "one or more numbers" you can use the + quantifier "\d+"

5
  • Just curious, does this also conform with the last part of the question? without replacing ... or MinCoverLevel="1.3" – TMH Sep 15 '15 at 10:00
  • @TomHart Yes it does. . is not a digit. – Johnbot Sep 15 '15 at 10:24
  • Ahh yeah, I didn't think about that! – TMH Sep 15 '15 at 10:30
  • 2
    He can type it as '\bCoverLevel=\d+' the \b means word boundary so it starts with CoverLevel and is not part of the string. Also don't forget that you have to replace with CoverLevel + new expression. – Zikato Sep 15 '15 at 11:01
  • And if XX was supposed to be limited to two digits (i.e. you don't want to replace CoverLevel="212", then you can use CoverLevel="\d\d?", where ? matches 0 or 1 instances. – Brian J Sep 15 '15 at 13:29
0

If you also want to leave something like SomeOtherCoverLevel="1234" untouched, you will need to use the following instead.

^CoverLevel="\d+"$

What you need is to delimit the begin and end to be sure nothing else is touched.

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.