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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:26:16+00:00 2026-06-11T05:26:16+00:00

is it possible to make a regex with multiple delimiters? For example I want

  • 0

is it possible to make a regex with multiple delimiters? For example I want to split a string which can come in two forms: 1. “string1, string2, string3” or 2. “string1,string2,string3”. I’ve been trying to do this in javascript but with no success so far.

  • 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-11T05:26:18+00:00Added an answer on June 11, 2026 at 5:26 am

    Just use a regex split():

    var string = "part1,part2, part3, part4,    part5",
        components = string.split(/,\s*/);
    

    JS Fiddle demo.

    The reason I’ve used * rather than ? is simply because it allows for no white-space or many white-spaces. Whereas the ? matches zero-or-one white-space (which is exactly what you asked, but even so).

    Incidentally, if there might possibly be white-spaces preceding the comma, then it might be worth amending the split() regex to:

    var string = "part1,part2  , part3, part4,    part5",
        components = string.split(/\s*,\s*/);
    console.log(components);​
    

    JS Fiddle demo.

    Which splits the supplied string on zero-or-more whitespace followed by a comma followed by zero-or-more white-space. This may, of course, be entirely unnecessary.

    References:

    • Regular Expressions.
    • string.split().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: RegEx to make sure that the string contains at least one lower
I want a regex that matches a string which contains - At least one
Is it possible to make a Func delegate an extension method? For example, just
i wonder if it's possible to make a RegEx for the following data pattern:
I want to know if it is possible to make a single regular expression
Possible Duplicate: Regex for checking if a string has mismatched parentheses? I'm trying to
I'm trying to create a regex so I can identify URLs in text. Possible
Can anyone help me make a regex or give me a good solution that
Is it possible to make a regex match only the first line of a
I need make a regex expression to validate an external string. I'm building a

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.