Skip to content

Commit 79491b1

Browse files
Move function to utils file
1 parent 8f8a294 commit 79491b1

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

ballerina/natives.bal

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,6 @@ public isolated function searchAll(string str, string regex) returns Match[] {
186186
return matched;
187187
}
188188

189-
isolated function getPartMatch(handle matcher, int groupCount, int startIndex = 0) returns PartMatch[] {
190-
int i = 0;
191-
PartMatch[] partMatch = [];
192-
while i <= groupCount {
193-
handle group = getGroup(matcher, i);
194-
string? valueInString = java:toString(group);
195-
if valueInString is string {
196-
partMatch.push(
197-
{
198-
matched: valueInString,
199-
startIndex: getGroupStartIndex(matcher, i) + startIndex,
200-
endIndex: getGroupEndIndex(matcher, i) + startIndex
201-
});
202-
}
203-
i += 1;
204-
}
205-
return partMatch;
206-
}
207189
// Interoperable external functions.
208190
isolated function matchesExternal(handle stringToMatch, handle regex) returns boolean = @java:Method {
209191
name: "matches",

ballerina/utils.bal

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,22 @@ readonly class MatchGroups {
5757
return self.partMatch[index];
5858
}
5959
}
60+
61+
isolated function getPartMatch(handle matcher, int groupCount, int startIndex = 0) returns PartMatch[] {
62+
int i = 0;
63+
PartMatch[] partMatch = [];
64+
while i <= groupCount {
65+
handle group = getGroup(matcher, i);
66+
string? valueInString = java:toString(group);
67+
if valueInString is string {
68+
partMatch.push(
69+
{
70+
matched: valueInString,
71+
startIndex: getGroupStartIndex(matcher, i) + startIndex,
72+
endIndex: getGroupEndIndex(matcher, i) + startIndex
73+
});
74+
}
75+
i += 1;
76+
}
77+
return partMatch;
78+
}

0 commit comments

Comments
 (0)