string - How to get variable between two charaters in PowerShell? -


i have powershell script gets part of string between >and <:

$splitarray = "sometext>myvariable<somemoretext" -split ">",0 $string = $splitarray[1] -split "<",0 $myvariable = $string[0] 

is there more efferent way of getting myvariable between > <?

you use regex replace:

$myvar = "sometext>myvariable<somemoretext" -replace '.+>(.+)<.+', '$1' 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -