I'm using Notepad++ to edit an XML file, and I'm trying to figure out how to make an edit to multiple records within the file. The problem is, I want to remove a specific string from a following line when I find a different string in the current line. Here's an example:
<id_type>OTHER_ID_1</id_type>
<value>joeblow@college.edu</value>
What I'm trying to do is remove @college.edu
from the following line whenever I find OTHER_ID_1
. I can't do a blanket find/replace of @college.edu
, because there are other XML tags in the file that need to have that information.
I've found a lot of code that seems to get me close, but all I seem to be able to do with it is to select it. I've also seen some examples that show how to capture the output in the "Find what:" box, but I can't seem to make it work with the previous examples I'm finding.
This is my current find code:
(?s)(?<=OTHER_ID_1</id_type>)(.+?)(?=</value>)
What's next? How can I remove @college.edu
from that selection?
A simple approach would be. Search for
<id_type>OTHER_ID_1<\/id_type>[^<]+<value>([a-zA-Z0-9.+]*)@college.edu<\/value>
Replace by
<id_type>OTHER_ID_1</id_type>\n<value>$1</value>
Important: Tick the check box that the regular expression also matches newline and carriage return when searching for "."
Note: The Regex for the name part of the email address is pretty simple :-)