Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To change multiple occurrences between two points in multiple files using regex, you can follow these steps:

  1. Identify the pattern of the text you want to change using regex. For example, if you want to change all occurrences of the word "apple" to "orange" between lines 10 and 20 in multiple files, your regex pattern could be:
(?<=line 10).*?(?=line 20).*?\bapple\b

This regex pattern will match all occurrences of the word "apple" between lines 10 and 20 in a file.

  1. Use a tool that supports regex search and replace across multiple files, such as Notepad++ or Sublime Text.

  2. Open the files you want to change and run a regex search using the pattern you identified in step 1.

  3. Once the search results are displayed, use the tool's replace function to replace all occurrences of the text with the new text you want. For example, to replace "apple" with "orange", enter the word "orange" in the Replace With field.

  4. Click the replace or replace all button to apply the changes.

  5. Save the modified files.

Repeat steps 3-6 for each file you want to modify.