Usando Regex em Powershell para pegar e-mail
Eu escrevi um script para pegar diferentes campos em um arquivo HTML e preencher variáveis com os resultados. Estou tendo problemas com a expressão regular para pegar o e-mail. Aqui está um código de amostra:
$txt='<p class=FillText><a name="InternetMail_P3"></a>[email protected]</p>'
$re='.*?'+'([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})'
if ($txt -match $re)
{
$email1=$matches[1]
write-host "$email1"
}
Estou tendo o erro a seguir:
Bad argument to operator '-match': parsing ".*?([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\
.)+[a-zA-Z]{2,7})([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})" - [x-y] range in reverse order..
At line:7 char:16
+ if ($txt -match <<<< $re)
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : BadOperatorArgument
O que estou perdendo aqui? Além disso, existe uma regex melhor para o email?
Desde já, obrigado.