I’m new to regex and I’m trying a simple one to see how they work.
My simple regex is “(\w+@\w+\w+)” to be able to capture some email from a big text.
I’ve created a text file, put into it a big chunk of random text, and inserted an email at 2 spots in there.
When I compare the file’s content to my regex, -match shows me the 2 lines with the email but what I see is the whole line, not the email I was looking for.
If I do $matches, I see no match.
Can someone please explain what I am doing wrong?
$file = get-content file.txt
$regex = “(\w+@\w+\w+)”
$file -match $regex