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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:23:28+00:00 2026-05-27T03:23:28+00:00

I validate my input if it passes both regex above. How can I tweak

  • 0

I validate my input if it passes both regex above.
How can I tweak both regex so that it accepts a list ie (like on input2 and input3). Right now my regex only work on input1.

2 or higher:

^\d{2}\d*$

non 0:

^[1-9]\d*$

input1: 123
input2: 123, 456
input3: 123, 456, 789
  • 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-27T03:23:29+00:00Added an answer on May 27, 2026 at 3:23 am

    First of all, the pattern you posted is equivalent to ^\d{2,}$, which requires the number to have two or more digits. The regex for an integer greater than or equal to 2 is more like ^[+-]?0*([2-9]|[1-9]\d+)$. From your description, it’s not clear which of these you intended.

    Either way, what you want to use is something like this:

    ^(<pattern>(,\s|$))+$`
    

    So for your scenario, it would be something like:

    ^(\d{2,}(,\s|$))+$                #2 or more digits
    ^(0*([2-9]|[1-9]\d+)(,\s|$))+$    #positive integers >= 2
    ^(0*[1-9]\d*)(,\s|$))+$           #positive integers > 0
    

    I’m not sure what flavor of regex you’re using, but if your engine balks at the redundant use of $ in the patterns above, you could try something like

    ^(<pattern>,\s)*<pattern>$
    

    instead. Example:

    ^(\d{2,},\s)*\d{,2}$    #2 or more digits, simplified
    

    Bear in mind that a better way to do this is usually to split the string on the comma + whitespace separator, which will give you an array of strings you can try to parse as integers.

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

Sidebar

Related Questions

I’m trying to validate input by using egrep and regex.Here is the line from
I'm trying to validate user input, which is just comma separated numbers. I'd like
I'd like to validate user input with regular expression in Django Admin CharField... How
Should I validate input parameters on all functions I create? Input isn't passed from
I'm looking into the various ways to validate input for an editable JComboBox. Currently,
to custom validate an input i wrote a script: function cardNumberCheck(value, element) { var
I'm trying to validate a input field with the JQuery validation plugin. The numeric
I am trying to validate an input field when it loses focus and re-focus
I am using regular expressions to validate user input. The following code collects a
Any ideas why this won't validate here: http://validator.w3.org/#validate_by_input It seems the form input tags

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.