Skip Menu |

This queue is for tickets about the Perl-Dist-Strawberry CPAN distribution.

Report information
The Basics
Id: 118096
Status: resolved
Priority: 0/
Queue: Perl-Dist-Strawberry

People
Owner: Nobody in particular
Requestors: andy.carver [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 06:45:55 +0200
To: bug-Perl-Dist-Strawberry [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
Escaping like \" does not work in MS Windows command prompt. Try ^" http://stackoverflow.com/questions/7760545/escape-double-quotes-in-parameter
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 06:01:44 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
Thank you for that suggestion. Unfortunately, it's not fixing it. Indeed, sometimes \" works: note, at the end of my little command-line program, the block {print $1.\", \";}  That part actually works. Some feedback the command line's giving me suggests that my first occurrence of \" is NOT getting passed thru to Perl... From: kmx via RT <bug-Perl-Dist-Strawberry@rt.cpan.org> To: andy.carver@yahoo.com Sent: Monday, 26 September 2016, 22:46 Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line <URL: https://rt.cpan.org/Ticket/Display.html?id=118096 > Escaping like \" does not work in MS Windows command prompt. Try ^" http://stackoverflow.com/questions/7760545/escape-double-quotes-in-parameter
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 09:15:41 +0200
To: bug-Perl-Dist-Strawberry [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
Well, command line escaping in Windows command prompt is a mess, try perl -w -n -e "if ( m/fldinst\{HYPERLINK """mailto:([^^^"""]+)/ ) {print $1.'""", """';}" "My List of people.rtf"
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 14:05:39 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
WELL DONE!!! You cracked the Windows command-line "mess"!!  In fact, to make it work I had only to make the changes you proposed to the regex!! Many thanks!! Now, would you be so kind also, as to tell me how you knew to try THOSE changes??
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 14:22:03 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
Experimenting further, it appears that only the change you proposed to the [] is required to get it to work!  That is to say, this program works:"if ( m/fldinst\{HYPERLINK \"mailto:([^^^"""]+)/ ) {print $1.\", \";}" whereas [^\"] does NOT work.  Since you know why that's so, could you please explain? :))
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 14:41:44 +0000 (UTC)
To: "andy.carver [...] yahoo.com" <andy.carver [...] yahoo.com>, "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: Andrew Carver <andy_carver [...] yahoo.com>
It looks like the problem was NOT double-quotes at all! It was only the ^ !!It works if changing [^\"] only to [^^^\"]
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 15:50:10 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
That's surprising, though, because I've never had to escape it when it's a start-of-line anchor -- as in /^
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 16:09:16 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
Maybe it's only because the ^ is directly followed by the double-quote. I've used ^ in the same way, but followed by \t instead of \", and it has worked:    perl -w -n -e "/(?:([^\t]*)\t){14}/; print $1.\"\n\";"
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 16:47:50 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
Anyway, thank you, to keep helping me with this even after it became clear it was a Windows issue, not Strawberry Perl, was very kind of you.
Subject: Re: [rt.cpan.org #118096] double-quotes in regex on command line
Date: Tue, 27 Sep 2016 20:07:52 +0200
To: bug-Perl-Dist-Strawberry [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
Ad your question couple of posts ago - frankly, I always simply experiment with command line escaping (putting proper number of " etc.) so long that I achieve what I wanted. stackoverflow.com is your friend :)
Subject: Re: [rt.cpan.org #118096] AutoReply: double-quotes in regex on command line
Date: Tue, 27 Sep 2016 02:29:08 +0000 (UTC)
To: "bug-Perl-Dist-Strawberry [...] rt.cpan.org" <bug-Perl-Dist-Strawberry [...] rt.cpan.org>
From: <andy.carver [...] yahoo.com>
P.S. When I wrote "single-quote", I meant double-quote. Sorry; guess I've got quote-marks on the brain. From: Bugs in Perl-Dist-Strawberry via RT <bug-Perl-Dist-Strawberry@rt.cpan.org> To: andy.carver@yahoo.com Sent: Monday, 26 September 2016, 20:09 Subject: [rt.cpan.org #118096] AutoReply: double-quotes in regex on command line Greetings, This message has been automatically generated in response to the creation of a trouble ticket regarding:     "double-quotes in regex on command line", a summary of which appears below. There is no need to reply to this message right now.  Your ticket has been assigned an ID of [rt.cpan.org #118096].  Your ticket is accessible on the web at:     https://rt.cpan.org/Ticket/Display.html?id=118096 Please include the string:         [rt.cpan.org #118096] in the subject line of all future correspondence about this issue. To do so, you may reply to this message.                         Thank you,                         bug-Perl-Dist-Strawberry@rt.cpan.org ------------------------------------------------------------------------- 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