Skip Menu |
 

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

Report information
The Basics
Id: 118096
Status: open
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>
Download (untitled) / with headers
text/plain 1.1k
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>
Download (untitled) / with headers
text/plain 148b
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>
Download (untitled) / with headers
text/plain 752b
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>
Download (untitled) / with headers
text/plain 187b
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>
Download (untitled) / with headers
text/plain 241b
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>
Download (untitled) / with headers
text/plain 308b
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>
Download (untitled) / with headers
text/plain 121b
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>
Download (untitled) / with headers
text/plain 108b
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>
Download (untitled) / with headers
text/plain 214b
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>
Download (untitled) / with headers
text/plain 141b
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>
Download (untitled) / with headers
text/plain 213b
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 :)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.