Skip Menu |
Report information
Id: 130586
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

Severity: (no value)
Tag: regex
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [REGEX] :sigspace does not affect spaces inside character classes
Download (untitled) / with headers
text/plain 659b
the :sigspace adverb does not affect spaces inside character class. Should it? Note that having JUST space inside also causes a weird error to be thrown: <Zoffix> m: say " " ~~ m:s/<-[ ]>/ <camelia> rakudo-moar 1aeea1: OUTPUT«===SORRY!===␤Iteration past end of iterator␤» <Zoffix> m: say " " ~~ m:s/<-[x ]>/ <camelia> rakudo-moar 1aeea1: OUTPUT«「 」␤» <Zoffix> m: say " " ~~ m:s/<-[ x]>/ <camelia> rakudo-moar 1aeea1: OUTPUT«「 」␤» <Zoffix> m: say " " ~~ m:sigspace/<-[ x]>/ <camelia> rakudo-moar 1aeea1: OUTPUT«「 」␤» <Zoffix> m: say " " ~~ m:sigspace/<[x ]>/ Discovery: https://irclog.perlgeek.de/perl6/2017-01-19#i_13948706
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 988b
On Wed, 18 Jan 2017 18:16:20 -0800, cpan@zoffix.com wrote: Show quoted text
> the :sigspace adverb does not affect spaces inside character class. > Should it? >
No, I don't think so. `<.ws>` can match any number of characters (including zero). A char class is defining something a matcher for a single character. Show quoted text
> Note that having JUST space inside also causes a weird error to be > thrown: > > <Zoffix> m: say " " ~~ m:s/<-[ ]>/ > <camelia> rakudo-moar 1aeea1: OUTPUT«===SORRY!===␤Iteration past end > of iterator␤» >
That one's certainly a bug. Since whitespace in a charclass is not significant, then it should complain about an empty charclass, preferably with a hint about space. Show quoted text
> <Zoffix> m: say " " ~~ m:s/<-[x ]>/ > <camelia> rakudo-moar 1aeea1: OUTPUT«「 」␤»
This matches because it's the same as m:s/<-[x]>/. You'd need to write <-[x\ ]> to make the space significant. Show quoted text
> <Zoffix> m: say " " ~~ m:s/<-[ x]>/ > <camelia> rakudo-moar 1aeea1: OUTPUT«「 」␤»
Ditto. /jnthn


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

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org