Tech Blog‎ > ‎

PowerShell - Strip Html Tags From a String

posted Jun 10, 2010, 5:44 AM by Victor Zakharov   [ updated Jul 26, 2010, 6:43 AM ]
Here's a one-liner: 

$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: http://en.wikipedia.org/wiki/Regular_expression, under Lazy quantification.
Comments