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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:14:56+00:00 2026-06-03T23:14:56+00:00

I’m new to regex and javascript and I was wondering if anyone knew what

  • 0

I’m new to regex and javascript and I was wondering if anyone knew what the regex would be for detecting whether or not if an input field contained the following type of format:

At least one alphanumeric and underscore( _ ) tag which can’t contain spaces (e.g “test” and “test_” but not “test test”)

Each tag seperated by a single comma (e.g “word1,word2,word_3, _word_4” but not “word1,,word2,word_3, _word_4) and any others symbos to be invalid (like ;!”‘@#%^&*()-+=.>

An example of what I mean is this, these would be valid tags:

something1,something_2,something_something,something
And these would be invalid tags:

something1%,something%2^,!something%_&something,(*)something@+

It should also be able to accept just a single tag, as multiples tags too!!

Thanks.

  • 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-03T23:14:57+00:00Added an answer on June 3, 2026 at 11:14 pm

    Presuming you want to accept both uppercase and lowercase characters:

    ^[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)*$
    

    The mentioned site has great information about regular expressions, I recommend reading through it. For now a short explanation:

    ^ means beginning of the string, so that no other (possibly invalid) characters can precede it. Between [ and ] is a character class: specifying what characters may follow. [ABC] for example means an A, a B or a C. You can also specify ranges like [A-E], which means an A, B, C, D or E.

    In the regular expression above I specify the range a to z, A to Z (uppercase), 0 to 9 and the single character _. The + means that the character, a group or a character from the character class preceding it must appear at least once or more.

    The ( and ) group a part of the regular expression. In this case they group the , (for the comma-separated list you wanted) and a repetition of the expression so far. The * means (like the +) that the group preceding it may appear many times, but with the difference that the * makes it optional.

    So, in short: this expression allows tags consisting of at least one or more characters in the range a-z, A-Z, 0-9 or the character _, optionally followed by more tags that begin with a ,, specifying the requirements for a comma-separated list 🙂

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

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.