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

  • Home
  • SEARCH
  • 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 7931959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:52:18+00:00 2026-06-03T20:52:18+00:00

If $text = ‘     MEANINGFUL THINGS GO HERE     ’; How can

  • 0

If

$text = '           MEANINGFUL THINGS GO HERE         ';

How can I get

$cleanText = 'MEANINGFUL THINGS GO HERE';

I know the following will remove all the white spaces

$text=trim($text);

but how can incorporate actual escaped space into the trim as well?

Meaningful Things can contain [shortcodes], html tags, and also escaped characters. I need these to be preserved.

Any help would be appreciated.
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-06-03T20:52:20+00:00Added an answer on June 3, 2026 at 8:52 pm
    $text = '           MEANINGFUL THINGS GO HERE         ';
    
    $text = preg_replace( "#(^( |\s)+|( |\s)+$)#", "", $text );
    
    var_dump( $text );
    
    //string(25) "MEANINGFUL THINGS GO HERE"
    

    additional tests

    $text = '       S       S    ';
    -->
    string(24) "S       S"
    
    $text = '                  ';
    -->
    string(0) ""
    
    $text = '         &nbst; &nbst;      ';
    -->
    string(18) "&nbst; &nbst;"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

text = urllib.urlopen('www.text.com').read() frase = re.search(your text here(.*), text).group() With these code, I get
Text : aaaa Pattern : aa then will two match: aa(0,1), aa(2,3) if I
Text data-bind expressions can have only a single property. How would I pluralize some
System.Text.RegularExpressions.Regex(#*#) is this correct..!? my text can be like #abc1234+as00# etc. ie, anything between
From text: Text... Target row Text... I need remove row with string ' Target
This is how I get the tags of a body of text. var tags
text block how to do: text trimming for a given height vertical alignment Can
Text File contents: &CRB A='test1' B=123,345, 678 &END Misc text potentially between entries ...
the text: aaa the regex: a{2} the answer of notepad++ (v5.9.6.2 (UNICODE)): Can't find
The text is: Here is some text! The regular expression (looking for a single

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.