user3197788
user3197788

Reputation: 165

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

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.

Upvotes: 0

Views: 35

Answers (1)

Amit Joki
Amit Joki

Reputation: 59282

You can use this regex.

(?!<.+?>)([^<>]+?)(?=</.+?>)

Upvotes: 1

Related Questions