Skip to content

Commit d347667

Browse files
Remove brackets
1 parent 01395ba commit d347667

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ballerina/natives.bal

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public isolated function matches(string stringToMatch, string regex) returns boo
4545
public isolated function replace(string originalString, string regex, Replacement replacement,
4646
int startIndex = 0) returns string {
4747
Match? matched = search(originalString, regex, startIndex);
48-
if (matched is null) {
48+
if matched is null {
4949
return originalString;
5050
}
5151
int index = 0;
5252
int length = originalString.length();
5353
string updatedString = strings:substring(originalString, index, matched.startIndex) +
5454
getReplacementString(matched, replacement);
5555
index = matched.endIndex;
56-
if (index < length) {
56+
if index < length {
5757
updatedString += strings:substring(originalString, index, length);
5858
}
5959
return updatedString;
@@ -84,7 +84,7 @@ public isolated function replaceAll(string originalString, string regex, Replace
8484
getReplacementString(matched, replacement);
8585
startIndex = matched.endIndex;
8686
}
87-
if (startIndex < originalString.length()) {
87+
if startIndex < originalString.length() {
8888
updatedString += strings:substring(originalString, startIndex, originalString.length());
8989
}
9090
return updatedString;
@@ -114,8 +114,9 @@ public isolated function replaceFirst(string originalString, string regex, strin
114114
if updatedString is string {
115115
return updatedString;
116116
}
117+
panic error(string `error occurred while replacing ${regex} in ${originalString}`);
117118
}
118-
return originalString;
119+
panic error(string `error occurred while replacing ${regex} in ${originalString}: ` + value.detail().toString());
119120
}
120121

121122
# Returns an array of strings by splitting a string using the provided

0 commit comments

Comments
 (0)