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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:26:31+00:00 2026-06-04T16:26:31+00:00

Like PHP strip punctuation , but I want to keep the apostrophe. Example: I’m

  • 0

Like PHP strip punctuation, but I want to keep the apostrophe.
Example:

I'm a student, but I don't like the school. I'll quit school.

The string after strip should be:

I'm a student but I don't like the school I'll quit school

How can I do that with regular expression or other ways?

  • 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-04T16:26:33+00:00Added an answer on June 4, 2026 at 4:26 pm

    If you want to support all Unicode punctuation characters as well then use this regex:

    $str = preg_replace("#((?!')\pP)+#", '', $str);
    

    This regex is matching Unicode punctuation character class \pP and match will avoid apostrophe character using negative lookahead.

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

Sidebar

Related Questions

I want to put my outputted PHP into a table but it doesn't like
I have a REST-like PHP service and i don't understand how invoke function of
I want to use boost::crc so that it works exactly like PHP's crc32() function.
I would like to have a php function that will strip any input and
I would like to filter a string and strip all characters that are not
I've seen dozens of PHP snippets that go like this: function DB_Quote($string) { if
I have a regex email pattern and would like to strip all but pattern-matched
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'm trying to strip all punctuation out of a string using a simple regular
How can I strip / remove all spaces of a string in PHP? I

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.