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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:46:36+00:00 2026-05-29T14:46:36+00:00

How can I get a regular expression that matches any string that has two

  • 0

How can I get a regular expression that matches any string that has two or more commas?
I guess this is better explained with an example of what should match and what shouldn’t

abcd,ef // Nop
abc,de,fg // Yup

// This is what I have so far, but it only matches consecutive commas
var patt = /\,{2,}/;

I’m not so good with regex and i couldn’t find anything useful. Any help is appreciated.

  • 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-29T14:46:38+00:00Added an answer on May 29, 2026 at 2:46 pm

    This will match a string with at least 2 commas (not colons):

    /,[^,]*,/

    That simply says “match a comma, followed by any number of non-comma characters, followed by another comma.” You could also do this:

    /,.*?,/

    .*? is like .*, but it matches as few characters as possible rather than as many as possible. That’s called a “reluctant” qualifier. (I hope regexps in your language of choice support them!)

    Someone suggested /,.*,/. That’s a very poor idea, because it will always run over the entire string, rather than stopping at the first 2 commas found. if the string is huge, that could be very slow.

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

Sidebar

Related Questions

I am trying to write a regular expression that matches only any of the
I'm trying to build a regular expression that matches regular expressions between two forward
How can I use a regular expression to get words that start with !
Can anyone get me with the regular expression to strip multiline comments and single
How can I get content of a DIV using regular expression. What I need
Consider the two following regular expression snippets and dummy HTML that it should be
I have this regular expression to get urls: (((ht|f)tp(s?))://)?(www.|[a-zA-Z].)[a-zA-Z0-9-.]+.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(:[0-9]+) (/($|[a-zA-Z0-9.\,\;\?\'\+&%\$#\=~_-]+)) And I want to
I have a regular expression in my PHP script like this: /(\b$term|$term\b)(?!([^<]+)?>)/iu This matches
I am trying to build a regular expression that does matches only string2 below.
Are Regular Expressions useful for a Web Designer (XHTML/CSS)? Can a web designer get

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.