In Perl6, no-break space is considered space, so
say 'Perl 6' ~~ / / # Please understand there's a no-break space in the middle
produces
Null regex not allowed
Solution is to quote the character, like so
say 'Perl 6' ~~ / ' ' / ; # OUTPUT: «「 」»
However, that does not work if you want to include a non-breaking space into a character class:
$str ~~ /<[ & < > " ' { ]>/ )
I could use Zs
, which is a space separator, but that one seems more broad... Any other way?
Quoting does not help, either. Question is, what character class should I use there?
In word processing and digital typesetting, a non-breaking space, , also called NBSP, required space, hard space, or fixed space (though it is not of fixed width), is a space character that prevents an automatic line break at its position.
A commonly used entity in HTML is the non-breaking space: A non-breaking space is a space that will not break into a new line.
Type where you want to insert an extra space. Add one non-breaking space character for every space you want to add. Unlike pressing the spacebar multiple times in your HTML code, typing more than once creates as many spaces as there are instances of .
HTML Non-Breaking Space ( ) The simplest way to add a space in HTML (besides hitting the spacebar) is with the non-breaking space entity, written as or  .
Try:
$str ~~ /<[ & < > " ' { \xA0 ]>/
or more readable:
$str ~~ /<[ & < > " ' { \c[NO-BREAK SPACE] ]>/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With