Regular Expressions
Okay you have a text file or log file that contains a lot of data e.g. you have the source code of a website with a lot of usefull links. Let's say you want to extract only all the links.
$var=get-content .\websitesourcefile.txt
$regex=[regex]"www.\w+\.\w+"
foreach ($m in $regex.matches($var)) {$m.value}
This will show you all the entries starting with www.something.something
This will not however get the sites that don't start with www. So let's get those too:
$var=get-content .\websitesourcefile.txt
$regex=[regex]"http\:\//\w+\.\w+\.\w{1,7}"
foreach ($m in $regex.matches($var)) {$m.value}
page revision: 1, last edited: 12 May 2010 09:18