Extract Text without Regular Expressions

by Aug 16, 2011

If you don't like creating Regular Expression patterns, here is a trick so you can easily find and extract text:

$text = 'The problem was discussed in KB552356. Mail feedback to tobias @powershell.com'
$words = $text -split ' '
$words -like 'KB*'
KB552356
$words -like '*@*.*'
tobias@powershell.com

By splitting the text into words, you can then use -like and simple patterns that use the "*" wildcard.

Twitter This Tip!
ReTweet this Tip!