You mention "piped" text. I just had this problem and was searching on stack. The answer for me was, findstr /R and the echo command have some weird quirks with pipes in DOS (or cmd).
I was trying to match files ending in .jpg, so to test, my command was:
echo "myfile spaces in name.jpg" | findstr /i /r "\.jpg$"
But that wasn't working. I used gnu utils to find out, echo with a space before the pipe inserts a SPACE in the output of the PIPE. Since I'm very used to UNIX style echo and regular expressions I did not expect the extra space inserted after the filename in my echo test.
To fix, I added a " *" (space-star) in the regex after the jpg, (to match 0 or more spaces):
echo "myfile spaces in name.jpg" | findstr /i /r "\.jpg *$"
That worked great.**
Proof using GNU's octal dump command (space is 040 in octal):
c:\>echo "myfile.jpg" | od -cb
0000000 " m y f i l e . j p g " \r \n
042 155 171 146 151 154 145 056 152 160 147 042 040 015 012
Now if I remove the space before the "|" pipe, it goes away:
c:\>echo "myfile.jpg"| od -cb
0000000 " m y f i l e . j p g " \r \n
042 155 171 146 151 154 145 056 152 160 147 042 015 012
This shouldn't happen in text files in DOS, nor most commands filtered through a pipe, but it will happen if you do quick command line tests using echo like I did.
** Another weird quirk (at least on my Win10 version of findstr), it ignores double-quotes near the end of the line.