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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:04:42+00:00 2026-06-04T05:04:42+00:00

Problem I’m having trouble with a regular expression. I have a set of strings.

  • 0

Problem

I’m having trouble with a regular expression.

I have a set of strings.

Example String

@param* URL url './' an absolute URL giving the base location of the image
@param* Function callback callback(indexInArray, valueOfElement) The function that will be executed on every object.
@param Function callback Null The function that will be executed when the image is clicked
@param String name 'this is a test name' the name to use when displaying the image
@param String name "this is a test name" the name to use when displaying the image

I’m splitting them on the new line to give me individual string.

var match = val.split("\n");

Each of these strings can be broken down into five values:

Variables

Example: @param Function callback Null The function that will be executed when the image is clicked

@param = required;
Function = type;
callback = name;
Null = default;
The function that will be executed when the image is clicked = description.

What I need is to break this string up into its parts taking into account all the different string possibilities, i’m having a hard time creating the regular expression that can split on all the different default and description posibilites.

I’m having a particular problems trying to get the defaultValue out when its a string in double or single quotes or when it’s in function notation.

Code

This is my current working code;

$.each(match, function(index, value) {
    var part = value.split(/\s/); //TODO need a regx to split this string correctly

    var required     = part[0];
    var type         = part[1];
    var name         = part[2];
    var defaultValue = part[3];
    var description  = part[4];
});

Summary

I need a single or multiple step regular expression that can break up all five examples above into the same five variables.

Edit: I apologies for not having had a go at the regular expression but i’m not sure where to start.

  • 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-04T05:04:44+00:00Added an answer on June 4, 2026 at 5:04 am

    Try this:

    var regExp = /^(@.+?)\s(.+?)\s(.+?)\s(\'.+?\'|\".+?\"|\w.+?\)|\w+?)\s(.*)$/;
    results = regExp.exec(value);
    
    var required     = results[0];
    var type         = results[1];
    var name         = results[2];
    var defaultValue = results[3];
    var description  = results[4];
    

    I tested quickly using http://regexhero.net/tester/ but other than that I didn’t test it.

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

Sidebar

Related Questions

Problem: I am having trouble implementing a recursive image lazy load in all relevant
Problem description I have 6 databases from 6 different machines, and having one cloud
Problem solved, see below Question I'm working in Flex Builder 3 and I have
Problem: I can set the exposureMode property of AVCaptureDevice, but it does not stay
Problem Description: We have a service which has applications for main mobile OS’s. We
Problem! I Have the following input (rules) from a flat file (talking about numeric
Problem PHP session in different folder. I have problem with PHP session. There are
Problem: I have 2 classes, DB class and a User class, that will work
Problem I have a xib file with a UIImageView over the top of the
Problem is like this: I have two winapi application's. There is only one way

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.