Use RegEx to Extract Text

by Aug 15, 2011

With Regular Expressions, you can easily extract matching text. Have a look:

$text = 'The problem was discussed in KB552356. Mail feedback to tobias @powershell.com'
$pattern = 'KB\d{4,6}'
if ($text -match $pattern) { $matches[0]}

Twitter This Tip!
ReTweet this Tip!