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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:37:21+00:00 2026-06-18T06:37:21+00:00

In my application client is uploading data from MS word to Textarea. My RegEx

  • 0

In my application client is uploading data from MS word to Textarea. My RegEx skills are not so good 🙂

I need a RegEx to filter all the junk characters from string and the only acceptable input is characters from keyboard.
i.e, A-Z, a-z, 0-9 and all the special chracters present on keyboard + all currency symbols.

EDIT: I want to allow only ascii codes including extended. http://www.asciitable.com/

  • 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-18T06:37:22+00:00Added an answer on June 18, 2026 at 6:37 am

    I have checked the ASCII table and all printable symbols it contains are present on any standard keyboard.

    It’s hard to tell what defines “special characters present on the keyboard” but I assume you mean printable non-alphanumeric characters. While all the unicode whitespace characters (non-braking space, zero-width word non-joiner…) are indeed “special”, they are absent from most keyboards. The backspace character, while present on most keyboards, is typically interpreted by the OS, so I assume you don’t want that. A similar argument applies to the tab key: while the tab character is easier to obtain than the newline character, it can’t normally be typed into a form input.

    Concerning currency symbols, the character class \p{Sc} covers them, and C# regex seems to support this class

    Non-US keyboards contain many more characters (symbols with diacritics, cyrillic, chinese/japanese/korean characters), but they don’t match your description of “A-Z, a-z, 0-9 and all the special chracters present on keyboard + all currency symbols”. Of special interest is the japanese end-of-sentence punctuation, which is a hollow circle instead of just a dot. However, while it matches your description, I believe you don’t want that either.

    C# also supports \p{isBasicLatin}, but that includes the ASCII control characters, which I assume you don’t want.

    To sum up: your description matches the entire printable ASCII range and the newline \n. To check a string is made out of these, use this regex:

    ^[\x20-\x7E\n\p{Sc}]$
    

    Reflecting your edit, also consider all printable ASCII characters (most currency symbols are absent, $ isn’t) + newline

    ^[\x20-\x7E\n]$
    

    or the entire ASCII range including the control characters and all ASCII whitespace:

    ^[\x00-\x7F]$
    ^[\p{isBasicLatin}]$
    

    Ref:
    MSDN character classes
    MSDN character escapes
    MSDN code example (adapted here):

    bool IsValid(string strIn)
    {
        // Return true if strIn is in valid format.
        return Regex.IsMatch(strIn, @"^[\x20-\x7E\n\p{Sc}]$");
    
    }
    

    regex replace (adapted here; strips out everything except A-Z, a-z , 0-9 and following characters. ~ ` ! @ # $ % ^ & * ( ) _ + | - = \ { } [ ] : " ; ' < > ? , . /)

    String CleanInput(string strIn)
    {
        // Replace invalid characters with empty strings.
        return Regex.Replace(strIn,
              @"[^a-zA-Z0-9`!@#$%^&*()_+|\-=\\{}\[\]:"";'<>?,./]", ""); 
    }
    

    Concerning double quotes inside verbatim string literals: http://blogs.msdn.com/b/gusperez/archive/2005/08/10/450257.aspx

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

Sidebar

Related Questions

I have an application where client and server share types, and interoperability is not
My script receives gzipped data from a desktop application via POST, which it retrieves
We are designing an application that needs to support uploading short audio files from
A client application is uploading an audio file in chunks to an MVC3 site.
I have an application that will upload files from my client to a web
I am uploading audio file in chunks from a Windows Phone client to an
i would make an application client server with java to change or modify the
I'm about to go into a large scale application (client-flex, server-.net). The server side
In a client application I have a DBIx::Class model 'Todo' that can be linked
A C# client application we developed calls an external SOAP web service of 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.