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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:41:45+00:00 2026-05-22T01:41:45+00:00

For a Username field there are certain varaitions that cannot be chosen as an

  • 0

For a Username field there are certain varaitions that cannot be chosen as an appropiate username nor can certain characters be used.

For example: TIM1….TIM9 cannot be used BIN1….BIN9 cannot be used, nor can the characters <>:\/|?* appear anywhere in the field.

The code I have so far is thus:

    private bool ValidateId(string regexValue)
    {
        Regex regex = new Regex("TIM[1-9]|BIN[1-9]|[<>:\"/|?*]");
        return !regex.IsMatch(regexValue);
    }

What I’m struggling to allow for however is the backslash character. Trying to escape it as I have done with the quotation character doesn’t appear to work.

Thanks in advance.

  • 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-22T01:41:45+00:00Added an answer on May 22, 2026 at 1:41 am

    You need to do a double escape. Try this:

    Regex regex = new Regex("TIM[1-9]|BIN[1-9]|[<>:\\\\\"/|?*]");
    

    Explanation:

    You need to escape the backslash in C# strings to get a backslash in the string. Additionally, the string needs to have two backslashes, because Regex also requires the backslashes to be escaped.

    BTW, using verbatim strings makes it a bit more readable:

    Regex regex = new Regex(@"TIM[1-9]|BIN[1-9]|[<>:\\""/|?*]");
    

    Both codes will result in a Regex with this expression:

    TIM[1-9]|BIN[1-9]|[<>:\\"/|?*]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to allow users to either have there username field empty at any
I have a login form that includes a username and password field. Users will
I have two text field boxes; username and password. There is also a checkbox
By default, Membership API uses a separate username field to login users. I would
I have an app, and the username field will convert any given value to
I'm trying to build a better username/password field for my workplace and would like
The following is a script which empties the Username text field and the Password
How do i override/set authlogic to use the email field instead of the username
I'm taking a look now to XtraReports reporting tool and there's something that I
I have a LINQ Statement. It searches an XML file. (See example below) There

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.