Problem
I am having problems with regex.
I have a rowset.
Line example
@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 am breaking them into a new line to give me a separate line.
var match = val.split("\n");
Each of these lines can be divided 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.
I need to break this string into its parts, taking into account all the different capabilities of the string, it is difficult for me to create a regular expression that can be broken into all different default descriptions and posibilites.
I am having special problems trying to get the defaultValue value when its string is in double or single quotes or when it is in function notation.
The code
This is my current working code;
$.each(match, function(index, value) {
var part = value.split(/\s/);
var required = part[0];
var type = part[1];
var name = part[2];
var defaultValue = part[3];
var description = part[4];
});
Summary
I need one or multi-step regex that can break all five examples above into the same five variables.
: , , , .