-2

I would like to replace all string that do not equal this: readWriteDataGroup="Everyone" on a file I have open in Notepadd++. One of the strings that it will need to replace has this string: readWriteDataGroup="E_MOD_WSP_64"

So I have been doing this manually but there is over 1000000 lines which is not feasible to be done manually.

How can I do this via regex?

logi-kal
  • 7,107
  • 6
  • 31
  • 43
Rehaan
  • 5
  • What is your regEx? search key `readWriteDataGroup="Everyone"`, and replace value `readWriteDataGroup="E_MOD_WSP_64"`, why would not this work? – Popeye Jul 19 '23 at 08:17
  • 1
    What is a "string that do not equal `readWriteDataGroup="Everyone"`"? What does it mean that "One of the strings [...] has this string"? – logi-kal Jul 19 '23 at 08:25
  • 1
    Please, [edit your question](https://stackoverflow.com/posts/76719228/edit) and add example lines from your file **and** expected result. As is, your question is really unclear. – Toto Jul 19 '23 at 08:59
  • 1
    Also, what have you already tried? – logi-kal Jul 19 '23 at 09:53

1 Answers1

0

If you search for (readWriteDataGroup=")(?!Everyone")[^"]*(") and replace it with $1X$2 then all the lines that do not contain Everyone in the quotation marks will be replaced with an X.

How that works:

In the search string

  • (readWriteDataGroup=") will match readWriteDataGroup=" and save it as $1
  • (?!Everyone")[^"]* will match any string that isn't Everyone
  • (") will match a trailing " and save it as $2

In the replacement:

  • $1 is the first capture group (readWriteDataGroup=")
  • X is the replacement text
  • $2 is the second capture group (")

You can try it here: https://regex101.com/r/Bum3HU/2

In Notepad++, make sure you select the "Regular Expression" button on the Replace dialog.

Jerry Jeremiah
  • 9,045
  • 2
  • 23
  • 32