What regex should be applied when selecting text between unknown XML tags but not the tags themselves?

StackOverflow https://stackoverflow.com/questions/23368260

  •  12-07-2023
  •  | 
  •  

Question

As the title suggests e.g.

<unknownTag>Select this only</unknownTag>
<anotherUnknownTag>Select this too</anotherUnknownTag>

To select: - Select this only - Select this too

A brief explanation on separate parts would be nice too if possible.

Was it helpful?

Solution

You can use this regex.

(?!<.+?>)([^<>]+?)(?=</.+?>)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top