# Created by Noah Coad on 7/6/2009
# Regular Expressions helpers

function match ([string]$source, [string]$regex) {[regex]::Matches($source, $regex) | %{$_.Value}}
function ListContainsRegex([string] $csvlist, [string] $term)
{
	$found=$False
	$csvlist.Split(";") | %{$regex=("\A" + $_.Trim() + "\z"); if ([regex]::IsMatch($term,$regex)) {$found=$True}}
	$found
}

# ListContainsRegex Unit Tests
# $words="zArchive;Music Only;Library;Movies;Music;aMain;Albums;Fixit;For Sharing; Unplayed.*; 90’s Music"
# ListContainsRegex $words "Library" // True case
# ListContainsRegex $words "Librarys" // False case
