There's \p{Zs} that matches a normal space and an nbsp and a few other oddities:
$ perl -le'use charnames (); use warnings; no warnings "utf8"; chr($_) +=~/[\p{Zs}]/ && printf "%.4x: %s\n", $_, charnames::viacode($_) for 0 +..65500' 0020: SPACE 00a0: NO-BREAK SPACE 1680: OGHAM SPACE MARK 180e: MONGOLIAN VOWEL SEPARATOR 2000: EN QUAD 2001: EM QUAD 2002: EN SPACE 2003: EM SPACE 2004: THREE-PER-EM SPACE 2005: FOUR-PER-EM SPACE 2006: SIX-PER-EM SPACE 2007: FIGURE SPACE 2008: PUNCTUATION SPACE 2009: THIN SPACE 200a: HAIR SPACE 202f: NARROW NO-BREAK SPACE 205f: MEDIUM MATHEMATICAL SPACE 3000: IDEOGRAPHIC SPACE
(\s also matches it, but only if perl has the string marked as utf8). But \p{Zs} expects an actual NO-BREAK SPACE character, not the HTML entity for one. If you want to include entities that represent space characters, you'd probably be best off using HTML::Entities to decode them first.

In reply to Re: nbsp in space character class by ysth
in thread nbsp in space character class by hsfrey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.