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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:05:37+00:00 2026-06-11T02:05:37+00:00

How to remove everything but: letters, numbers, spaces, exclamation marks, question marks from a

  • 0

How to remove everything but:

letters, numbers, spaces, exclamation marks, question marks from a string?

It’s important that the method supports international languages (UTF-8).

  • 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-11T02:05:38+00:00Added an answer on June 11, 2026 at 2:05 am

    You can use regex

    myString.replace(/[^\w\s!?]/g,'');
    

    This will replace everything but a word character, space, exclamation mark, or question.

    Character Class: \w stands for “word character”, usually [A-Za-z0-9_]. Notice the inclusion of the underscore and digits.

    \s stands for “whitespace character”. It includes [ \t\r\n].

    If you don’t want the underscore, you can use just [A-Za-z0-9].

    myString.replace(/[^A-Za-z0-9\s!?]/g,'');
    

    For unicode characters, you can add something like \u0000-\u0080 to the expression. That will exclude all characters within that unicode range. You’ll have to specify the range for the characters you don’t want removed. You can see all the codes on Unicode Map. Just add in the characters you want kept or a range of characters.

    For example:

    myString.replace(/[^A-Za-z0-9\s!?\u0000-\u0080\u0082]/g,'');
    

    This will allow all the previously mentioned characters, the range from \u0000-\u0080 and \u0082. It will remove \u0081.

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

Sidebar

Related Questions

I'm trying to remove everything from a string that is NOT an html tag
Possible Duplicate: PHP code to remove everything but numbers i have a loop that
How can I remove a file from my last commit, but keep everything else?
I'm trying to remove everything except valid letters (from any language) in PHP. I've
I would like to remove everything but the Characters a-z,A-Z and 0-9 from a
I have a string Mod. 816-10 025 and I want to remove everything but
I am trying to remove everything between curly braces in a string, and trying
How do I remove everything beginning in '<' and ending in '>' from a
I have a string: HLN (Formerly Headline News) I want to remove everything inside
I have a string 2500 - SomeValue. How can I remove everything before the

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.