new RegexMap(def)
Creates a regular expression generator, which matches multiple alternative strings and can return its value.
Parameters:
Name | Type | Description |
---|---|---|
map[].str |
Array.<string> | The strings to be matched. Use ~ as first or last character for indicating a whole word. |
map[].val |
any | The match value. |
def |
string | The default value to return when a value is not found. |
- Source:
Methods
get(matches, pos, ldefopt) → {string}
Look for a value in matches at given pos position and checks its value. When not found constructor default or ldef is returned.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
matches |
Array.<string> | The values set to be check. | ||
pos |
number | The position in matches to be checked. | ||
ldef |
any |
<optional> |
(constructor def) | Value to be returned if value doesn't match. |
- Source:
Returns:
The matched value.
- Type
- string
regex(mustopt) → {string}
Produces the relative regular expression chunk.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
must |
boolean |
<optional> |
false | Specify if the regular expression chunk must be found in order to match. |
- Source:
Returns:
The regular expression chunk.
- Type
- string