Regular Expression for alphanumeric and underscores

0 votes
I wanted to have a regular expression that checks if a string contains only upper and lowercase letters, numbers, and underscores. Is it possible? If yes how can I do it ?
May 23, 2022 in Others by Kichu
• 19,040 points
968 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

To match a string that contains only those characters (or an empty string), try:

"^[a-zA-Z0-9_]*$"

Note this this will help you:

^ : start of string
[ : beginning of character group
a-z : any lowercase letter
A-Z : any uppercase letter
0-9 : any digit
_ : underscore
] : end of character group
* : zero or more of the given characters
$ : end of string

If you don't want to allow empty strings, use + instead of *.

answered May 27, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In Others

0 votes
1 answer

AngularJS SEO - Once and for all

java script cant be or wont be ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,600 points
758 views
0 votes
0 answers

Replacing H1 text with a logo image: best method for SEO and accessibility?

i want to link my logo to ...READ MORE

Feb 14, 2022 in Others by Kichu
• 19,040 points
3,073 views
0 votes
1 answer

AngularJS SEO - Once and for all

javascript is not compiled by google bots ...READ MORE

answered Feb 20, 2022 in Others by narikkadan
• 63,600 points
709 views
0 votes
1 answer

Rendertron for NuxtJS and Firestore site for SEO purposes

reconfigue the server setting  app.use(rendertron.makeMiddleware({ proxyUrl: 'https://ampedcast-7c1d6.uc.r.appspot.com/render', ...READ MORE

answered Feb 21, 2022 in Others by narikkadan
• 63,600 points
937 views
0 votes
1 answer

Removing all white-spaces from a string

You can use the 'str_replace_all()' function from ...READ MORE

answered May 16, 2018 in Data Analytics by Bharani
• 4,660 points
695 views
0 votes
1 answer

What Regex to use to identify a Block Hash?

Blockhashes are always 64 characters in length. You ...READ MORE

answered Aug 28, 2018 in Blockchain by digger
• 26,740 points
2,030 views
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,840 points
924 views
0 votes
1 answer

.replace() regex in Python

No,  .replace() does not support regex. Regular expressions ...READ MORE

answered Nov 26, 2018 in Python by SDeb
• 13,300 points
1,116 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP