This page looks best with JavaScript enabled

PowerShell - Strip Html Tags From a String

 ·   ·  ☕ 1 min read

Here’s a one-liner:

1
$myStr -replace "<.*?>" 

Explanation

With the above line, we are removing every shortest set of symbols within triangle brackets. The word shortest is very important here. Have a look at this wiki page for more information about greedy and lazy matching, under Lazy quantification.


Victor Zakharov
WRITTEN BY
Victor Zakharov
Web Developer (Angular/.NET)