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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:36:12+00:00 2026-06-03T22:36:12+00:00

Not a big user of RegEx – never really understood them! However, I feel

  • 0

Not a big user of RegEx – never really understood them! However, I feel the best way to check input for a username field would be with one that only allows Letters (upper or lower), numbers and the _ character, and must start with a letter as per the site policy. The My RegEx and code is as such:

var theCheck = /[a-zA-Z]|\d|_$/g;
alert(theCheck.test(theUsername));

Despite trying with various combinations, everything is returning “true”.

Can anyone help?

  • 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-03T22:36:13+00:00Added an answer on June 3, 2026 at 10:36 pm

    Your regex is saying “does theUsername contain a letter, digit, or end with underscore”.

    Try this instead:

    var theCheck = /^[a-z]([a-z_\d]*)$/i; // the "i" is "ignore case"
    

    This says “theUsername starts with a letter and only contains letters, digits, or underscores”.

    Note: I don’t think you need the “g” here, that means “all matches”. We just want to test the whole string.

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

Sidebar

Related Questions

This is not a big deal, but is there any way in F# to
I'm not a big tomcat user, but our project is using it currently. We've
I'm not a big fan of XML files. Therefore I'm wondering if there is
Not sure if this is a big deal. But wondering why when the site
Does any know of a good calendar (not datepicker, but a BIG browsable calendar)
Apparently, there's been a big brouhaha over whether or not Python needs tail-call optimization
In C++, how do I combine (note: not add) two integers into one big
Not crazy about the way Xcode 4.2 has laid out the files on disk.
I've got the common situation where I've got user input that uses a subset
I am not a big expert on Facebook and Twitter APIs and I would

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.