add namedGroup function to nodejs RMatch

This commit is contained in:
2021-11-29 16:20:31 -07:00
parent 190b5ce1d2
commit 440c07a112
2 changed files with 5 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ typedef RMatch = {
#if hxnodejs
groups:Array<String>,
namedGroups:DynamicAccess<String>,
namedGroup:String->String,
#end
group:Int->String
};

View File

@@ -6,6 +6,7 @@
(var capitalLetter "[A-Z]")
(var smallLetter "[a-z]")
(var anyLetter "[A-Za-z]")
(var anyDigit "[0-9]")
(function :String _group [:Array<Dynamic> exprs]
(+ "(" (apply + (assert exprs)) ")"))
@@ -59,7 +60,9 @@
groups
match
namedGroups
match.groups))
match.groups
namedGroup
->name (dictGet match.groups name)))
(let [r (new EReg regex /*TODO use or for this once fixed */(if flags flags ""))]
(if (r.match textToSearch)
(object