Regex to match tag contents while simultaneously omitting leading and trailing whitespace -



Regex to match tag contents while simultaneously omitting leading and trailing whitespace -

i trying write regex matches entire contents of tag, minus leading or trailing whitespace. here boiled-down illustration of input:

<tag> text </tag>

i want next matched (note how whitespace before , after match has been trimmed):

"text"

i trying utilize regex in .net (powershell):

(?<=<tag>(\s)*).*?(?=(\s)*</tag>)

however, regex matches "text" plus leading whitespace within of tag, undesired. how can prepare regex work expected?

drop lookarounds; create job more complicated needs be. instead, utilize capturing grouping pick out part want:

<tag>\s*(.*?)\s*</tag>

the part want available $matches[1].

regex whitespace lookbehind lookahead removing-whitespace

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -