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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:32:53+00:00 2026-05-19T11:32:53+00:00

I use these lines of code to remove all punctuation marks, symbols, etc as

  • 0

I use these lines of code to remove all punctuation marks, symbols, etc as you can see them in the array,

$pattern_page = array("+",",",".","-","'","\"","&","!","?",":",";","#","~","=","/","$","£","^","(",")","_","<",">");

$pg_url = str_replace($pattern_page, ' ', strtolower($pg_url));

but I want to make it simpler as it looks silly to list all the stuff I want to remove in the array as there might be some other special characters I want to remove.

I thought of using the regular expression below,

$pg_url = preg_replace("/\W+/", " ", $pg_url);

but it doesn’t remove under-score – _

What is the best way to remove all these stuff? Can regular expression do that?

  • 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-19T11:32:54+00:00Added an answer on May 19, 2026 at 11:32 am

    Depending on how greedy you’d like to be, you could do something like:

    $pg_url = preg_replace("/[^a-zA-Z 0-9]+/", " ", $pg_url);
    

    This will replace anything that isn’t a letter, number or space.

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

Sidebar

Related Questions

How can I use DOM parser to remove all attributes in span tags but
1) Isn't it a bad practice to use these attributes on all of my
Can I get a 'when to use' for these and others? <% %> <%#
I normally in my projects use such these code: If user.IsInRole(Admin) Then deleteButton.Visible =
I'd like to have these lines of code executed on server startup (both development
I know how I use these terms, but I'm wondering if there are accepted
Is there a way to use these operators to input and output binary data?
App Engine only allows you to use these formats for XMPP addresses: app-id@appspot.com anything@app-id.appspotchat.com
I have an IDictionary, now I want to use these values in a selectlist.
I run a rather complex project with several independent applications. These use however a

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.