I am trying to extract an URL from the Body of a Mail in PowerShell.
I am using following regex: (found on this site)
$regexURL = "@^(https?|ftp)://[^\s/$.?#].[^\s]*$@iS"
then I loop into a Mail folder and for each mail-item:
foreach ($Mail in $subfolder.items) {
$a = [Regex]::Match($Mail.Subject, $regexURL).Groups[1].Value
$b = [Regex]::Match($Mail.Body, $regexURL).Groups[1].Value
}
But even when Mail.Subject or Body contains a valid URL, $a and $b stay empty.
I am afraid I did not understand how is Match() working.
Thanx for any help on that question. Jerome
$Mail.Subjectand what you expect$ato be.@good for? Seems to be regex for another language. Try$regexURL = '(https?|ftp)://[^\s/$.?#].[^\s]*$'.iSmodifiers is not required in PS/.NET AFAIK.