I have following xml tags:
<EmployerName>company name</EmployerName>
and <Email>name@gmail.com</Email>
I am using the following regular expression-
<EmployerName>[0-9A-Z:-]*</EmployerName>
to remove the data between tags. But, the data is not getting removed. Any idea?
If you want to match everything within the tags, just use .
:
<EmployerName>.*</EmployerName>
Your character group [0-9A-Z:-]
covers digits, letters, the colon and the hyphen characters, but it doesn't include whitespace or other special characters.
Then you can replace with simply <EmployerName></EmployerName>
.
In case there are multiple EmployerName
elements on the same line, use a reluctant match:
<EmployerName>.*?</EmployerName>
Your expression is missing the space “company name”. Try replacing the following:
(<\/?(?:EmployerName|Email)>)[a-z \.@]+(<\/?(?:EmployerName|Email)>)
… with $1$2
. Backreferencing didn’t work in Notepad++, so it’s a little verbose.
<EmployerName>[^<]*</EmployerName>
The working DEMO