Subject: | double-quotes in regex on command line |
Date: | Tue, 27 Sep 2016 02:06:18 +0000 (UTC) |
To: | "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org> |
From: | <andy.carver [...] yahoo.com> |
Hi,
I doubt I 'm the first person to notice this. Seems like I've got to be overlooking something.
Here is a command line I ran on an RTF file, to extract some email addresses from it. You'll note that the program is on the command line too:
perl -w -n -e "if ( m/fldinst\{HYPERLINK \"mailto:([^\"]+)/ ) {print $1.\", \";}" "My List of people.rtf"
This being Windows, I had to escape the " in several places in the code, to get things to run. Notably, that worked in some places, not in others.
In particular, the first occurrence of it, inside the regex, did not work; it would not match a single-quote in my data. (This was pure ANSI text I fed it, no Unicode. Changing the \" to \W made it run.) On the other hand, the second occurrence, still inside the regex but within [^\"], did work.
I used the latest 32-bit install, "perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32-x86-multi-thread-64int". I'm on Windows 10.
This is not major; but if folks don't know about it, it can be perplexing! (Then again, maybe I'M the only one who didn't know... :-/ It does seem like it might be just an unavoidable downside of using Windows...)
Many thanks,
Andy