RegExpIterate(string, string, int, int)

From NWN Lexicon
Jump to navigationJump to search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

Iterates sValue with sRegExp.

json RegExpIterate(
    string sRegExp,
    string sValue,
    int nSyntaxFlags = REGEXP_ECMASCRIPT,
    int nMatchFlags = REGEXP_FORMAT_DEFAULT
);

Parameters

sRegExp
The regular expression string.
sValue
A string value to operate upon with the regular expression.
nSyntaxFlags
nSyntaxFlags is a mask of REGEXP_* constants.
nMatchFlags
nMatchFlags is a mask of REGEXP_MATCH_* and REGEXP_FORMAT_* constants.


Description

Iterates sValue with sRegExp.

  • Returns an array of arrays; where each sub-array contains first the full match and then all matched groups.
  • Returns empty JSON_ARRAY if no matches are found.
  • If there was an error, the function will return JSON_NULL, with a error string filled in.
  • nSyntaxFlags is a mask of REGEXP_*
  • nMatchFlags is a mask of REGEXP_MATCH_* and REGEXP_FORMAT_*.


Remarks

Information icon.png This section of the article is a stub. You can help the NWN Lexicon by expanding it.


Version

This function was added in 1.86.8193.35 of NWN:EE.


Example

* RegExpIterate("(\\d)(\\S+)", "1i 2am 3 4asentence"); -> [["1i", "1", "i"], ["2am", "2", "am"], ["4sentence", "4", "sentence"]]


See Also

functions:

RegExpMatch() RegExpReplace()

constants:

REGEXP_* REGEXP_MATCH_* REGEXP_FORMAT_*


 author: Shadguy