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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:58:35+00:00 2026-06-06T02:58:35+00:00

In my bio information users sometimes input sentences without using the proper spacing, like

  • 0

In my bio information users sometimes input sentences without using the proper spacing, like this:

$bio = 'Hey there,I'm Tom!And I'm 25';

I use preg replace to fix the commas:

$bio = str_replace(",", ", ", $bio);

Which echo’s:

$bio = 'Hey there, I'm Tom!And I'm 25';

How do I do this for all the other punctuation signs except ‘ (from I’m) ?

Any ideas?

  • 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-06T02:58:37+00:00Added an answer on June 6, 2026 at 2:58 am

    you can use preg_replace with arrays.

    first create an array signs to replace like:

    $signs = array('/,/', '/!/', '/?/');
    

    than another array with the replacements

    $replacement = array(', ', '! ', '? ');
    

    now use both arrays with preg_replace:

    preg_replace($signs, $replacement, $bio);
    

    to be sure the next sign is’nt already a whitspace you could use a more complex regular expression for each character like this one:

    $signs = array('/,(\S)/', '/!(\S)/', '/?(\S)/');
    $replacement = array(', $1', '! $1', '? $1');
    

    http://php.net/manual/de/function.preg-replace.php

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

Sidebar

Related Questions

I'm wrapping text around an image using markup something like this: CSS: #imgAuthor {
In haml, I have something like this: #profile #photo #bio But what hapens is
Is there a python interface to GBrowse, something like Bio::Graphics in perl ? Otherwise,
In code, I sometimes see people specify constants in hex format like this: const
I want to rewrite an url like this: http://www.piata-bio.ro/presa-bio.php?var1=http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHmU7U7bXtlH9Lo8dXfBs64PqxgbA&url=http://www.eva.ro/divertisment/stiri/un-nou-concept-de-magazin-articol-35491.html to something like this :
I have this query: $result = mysql_query(SELECT id,pic0,bio,url FROM .$table. WHERE id LIKE '%custom%'
I have bio information inside a variable: $bio = 'text, text, text...'; I trim
I'm using openssl BIO objects to convert a binary string into a base64 string.
On this page: http://www.anasiamusic.com/bio.html in the body text (Ana Sia's DJ crate is a
I am using Bio::PopGen::PopStats to calculate Wright's F st for each line I read

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.