1

I have many text files and im trying to mass find and replace lines like the following :

  • rarePrefixTableLevelMax10,120,
  • rarePrefixTableLevelMax12,120,
  • rarePrefixTableLevelMax15,120,

The format is basically rarePrefixTableLevelMax[XX],120, where the XX in the brackets can vary.

Ive got a regex that can find these lines just fine :

 rarePrefixTableLevelMax([0-2]?[0-9]|30),120,

The problem is i cant figure out how to replace just the "120" with "500" and only for the valid lines. I was using a program called "find and replace" AKA fnr.exe and it cant seem to handle using regex for replacing text, it only seems to support using regex to search.

Any ideas on what i can use or how i can go about doing this?

Edit : Just to be clear, i need to be able this for many files at once, i cannot go into each file manually to do this as there are too many files.

1 Answer 1

2
  • Ctrl+H
  • Find what: rarePrefixTableLevelMax(?:[0-2]?[0-9]|30),\K120(?=,)
  • Replace with: 500
  • TICK Match case
  • TICK Wrap around
  • SELECT Regular expression
  • Replace all

Explanation:

rarePrefixTableLevelMax     # literally
(?:[0-2]?[0-9]|30)          # non capture group, number from 0 upto 30
,                           # a comma
\K                          # forget all we have seen until this position
120                         # 120
(?=,)                       # positive lookahead, make sure we have a comma after

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

4
  • @Toto: Im confused by how this helps. As i said, i need to do this for many files. It looks like you are going into notepad++ and doing this for each file manually, but i have 100+ files to go through. I cant go into each file manually. I need something that can do it for all the files in a batch.
    – Question
    Jun 16, 2023 at 9:44
  • 1
    @Question: In the replace dialog box, jump to "Find in Files" tab. Define the filters according to the files you want to modify and select the directory where they are located. Then click on Replace in Files. The Find what and Replace with boxes are the same. It could be usefull to make a backup before!
    – Toto
    Jun 16, 2023 at 9:53
  • @Question: Does it work for you?
    – Toto
    Jun 17, 2023 at 8:05
  • Thanks, i think it worked. (Dont know why the site wont let me @ you anymore.)
    – Question
    Jun 19, 2023 at 18:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .