Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 927941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:55:52+00:00 2026-05-15T19:55:52+00:00

I know that there are many types of space (em space, en space, thin

  • 0

I know that there are many types of space (em space, en space, thin space, non-breaking space, etc), but, all these, that I refered, have HTML entities (at least, PHP’s htmlentities() return something like  .

But, what about those spaces that have no HTML entities?
Example: [example URL not valid anymore]
Look at the nickname of this account. It has many ” ” (spaces) at the front, which are visible for us (this doesn’t happen with the  ).

I tried already filter with regular expressions, using \x escape, filter with str_replace(), with the space as the argument, and no luck at all!

Do you have any suggestion on how to filter ALL types of whitespace?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:55:53+00:00Added an answer on May 15, 2026 at 7:55 pm

    \s by default, will not match whitespace characters with values greater than 128. To get at those, you can instead make good use of other UTF-8-aware sequences.


    (Standard disclaimer: I’m skimming the PCRE source code to compile the lists below, I may miss a character or type something incorrectly. Please forgive me.)

    \p{Zs} matches:

    • U+0020 Space
    • U+00A0 No-break space
    • U+1680 Ogham space mark
    • U+180E Mongolian vowel separator
    • U+2000 En quad
    • U+2001 Em quad
    • U+2002 En space
    • U+2003 Em space
    • U+2004 Three-per-em space
    • U+2005 Four-per-em space
    • U+2006 Six-per-em space
    • U+2007 Figure space
    • U+2008 Punctuation space
    • U+2009 Thin space
    • U+200A Hair space
    • U+202F Narrow no-break space
    • U+205F Medium mathematical space
    • U+3000 Ideographic space

    \h (Horizontal whitespace) matches the same as \p{Zs} above, plus

    • U+0009 Horizontal tab.

    Similarly for matching vertical whitespace there are a few options.

    \p{Zl} matches U+2028 Line separator.

    \p{Zp} matches U+2029 Paragraph separator.

    \v (Vertical whitespace) matches \p{Zl}, \p{Zp} and the following

    • U+000A Linefeed
    • U+000B Vertical tab
    • U+000C Formfeed
    • U+000D Carriage return
    • U+0085 Next line

    Going back to the beginning, in UTF-8 mode (i.e. using the u pattern modifier) \s will match any character that \p{Z} matches (which is anything that \p{Zs}, \p{Zl} and \p{Zp} will match), plus

    • U+0009 Horizontal tab
    • U+000A Linefeed
    • U+000C Formfeed
    • U+000D Carriage return

    To cut a long story short (I bet you read all of the above, didn’t you?) you might want to use \s but make sure to be in UTF-8 mode like /\s/u. Putting that to some practical use, to filter out those matching whitespace characters from a string you would do something like

    $new_string = preg_replace('/\s/u', '', $old_string);
    

    Finally, if you really, really care about the vertical whitespaces which aren’t included in \s (LF and NEL) then you can use the character class [\s\v] to match all 26 of the whitespace characters listed above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many things that all programmers should know, but I am particularly interested
I know that there are many Delphi database related questions available, but I'm considering
First of all: I do know that there are already many questions and answers
NOTE: I know there are many questions that talked about that but I'm still
I know that there are many ASN.1 parser out there but they cost quite
I know that there are many different questions about this sort of topic on
Firstly I know that there are many question and solutions to correct thread marshalling
It's my first question on SO. I know that there were many topics on
I know that there are so many standards for writing code. And some policy
I know there are many discussions about the emulator which is so slow that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.