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 1009697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:58:06+00:00 2026-05-16T08:58:06+00:00

I try to delete more then one white characters from my string: $content =

  • 0

I try to delete more then one white characters from my string:

$content = preg_replace('/\s+/', " ", $content); //in some cases it doesn't work

but when i wrote

$content = preg_replace('/\s\s+/', " ", $content); //works fine

could somebody explain why?

because when i write /\s+/ it must match all with one or more white character, why it doesn’t work?

Thanks

  • 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-16T08:58:07+00:00Added an answer on May 16, 2026 at 8:58 am

    What is the minimum number of whitespace characters you want to match?

    \s+ is equivalent to \s\s* — one mandatory whitespace character followed by any number more of them.

    \s\s+ is equivalent to \s\s\s* — two mandatory whitespace characters followed by any number more (if this is what you want, it might be clearer as \s{2,}).

    Also note that $content = preg_replace('/\s+/', " ", $content); will replace any single spaces in $content with a single space. In other words, if your string only contains single spaces, the result will be no change.

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

Sidebar

Related Questions

i used v s 2010 i have one problem..when i delete more then one
I'm looking to try to make an efficient delete method to work on a
How does one use rm to delete a file named '--help'? When I try,
I want to load the ASPNET runtime, run one or more pages, then unload
I'm currently doing some test where I try to delete a site collection programmatically.
An hacker have much more chance to try to inject this query: ') DELETE
I try to delete a record in Gridview and Database .I added a boundfield
when i try to delete the entity Visual Studio keeps crashing on the line
I am using the following code to try and delete entire rows when it
this is so that I will have to build a delete function, I try

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.