I am trying to write a regex that matches entire contents of a tag, minus any leading or trailing whitespace. Here is a boiled-down example of the input:
<tag
>
text
</tag
>
I want only the following to be matched (note how the whitespace before and after the match has been trimmed):
"text"
I am currently trying to use this regex in .NET (Powershell):
(?<=<tag>(\s)*).*?(?=(\s)*</tag>)
However, this regex matches "text" plus the leading whitespace inside of the tag, which is undesired. How can I fix my regex to work as expected?