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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:29:25+00:00 2026-05-31T15:29:25+00:00

Possible Duplicate: JavaScript RegExp Three Parts I need a help with regular expressions in

  • 0

Possible Duplicate:
JavaScript RegExp Three Parts

I need a help with regular expressions in JavaScript (Sorry, I’m still trying to learn it.).

I have this strings:

all (any) -del
all -del (any)
all (any)
all -del
all

PS: all, any and del can assume any value, including spaces.

And I need to separate each string:

var1 = all
var2 = any (or null)
var3 = del (or null)

Can you help me with this? 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-05-31T15:29:26+00:00Added an answer on May 31, 2026 at 3:29 pm

    How about:

    /^(.*?)\s?(\(.*?\)|)\s?(-.*?|)$/
    

    application to your examples:

    'all (any) -del'.match(/^(.*?)\s?(\(.*?\)|)\s?(-.*?|)$/)
    ["all (any) -del", "all", "(any)", "-del"]
    
    'all (any)'.match(/^(.*?)\s?(\(.*?\)|)\s?(-.*?|)$/)
    ["all (any)", "all", "(any)", ""]
    
    'all -del'.match(/^(.*?)\s?(\(.*?\)|)\s?(-.*?|)$/)
    ["all -del", "all", "", "-del"]
    
    'all'.match(/^(.*?)\s?(\(.*?\)|)\s?(-.*?|)$/)
    ["all", "all", "", ""]
    

    To process new requirement, a little bit complex:

    'all (any) -del'.match(/^(.*?)(?:\s?(\([^-]*\)|)\s?(-[^()]*|)|\s?(-[^()]*|)\s?(\([^-]*\)|))$/)
    ["all (any) -del", "all", "(any)", "-del", undefined, undefined]
    'all -del (any)'.match(/^(.*?)(?:\s?(\([^-]*\)|)\s?(-[^()]*|)|\s?(-[^()]*|)\s?(\([^-]*\)|))$/)
    ["all -del (any)", "all", undefined, undefined, "-del ", "(any)"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Javascript Regexp dynamic generation? I am trying to create a new RegExp
Possible Duplicate: Escape string for use in Javascript regex I have a msg like
Possible Duplicate: JavaScript Function Definition in ASP User Control Hi, I have a generic
Possible Duplicate: Graph visualization code in javascript? I have to integrate a graph with
Possible Duplicate: JavaScript replace all / with \ in a string? I have a
Possible Duplicate: Decode obfuscated JavaScript Question: I have the following javascript code: var _0xe91d=[\x28\x35\x28\x24\x29\x7B\x24\x2E\x32\x77\x2E
Possible Duplicate: How do you pass a variable to a Regular Expression JavaScript? This
Possible Duplicate: JavaScript: Class.method vs. Class.prototype.method I am trying to understand object in JavaScript.
Possible Duplicate: JavaScript post request like a form submit I have a value calculated
Possible Duplicate: JavaScript: formatting number with exactly two decimals Now that I have got

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.