无法在 Ballerina 上导入 stringutils

Can't import stringutils on Ballerina

我正在尝试使用以下代码进行基础操作:

import ballerina/io;
import ballerina/stringutils;
 
public function main() {
    string str1 = "Comparing String";
    string str2 = "cOmpaRinG sTrinG";
    io:print("String '" + str1 + "' and '" + str2 + "' are");
    if (stringutils:equalsIgnoreCase(str1, str2)) {
        io:println(" equal");
    } else {
        io:println(" not equal");
    }
}

但是我得到一个错误:

caio@german_shepherd test % bal run ./string.bal
Compiling source
    string.bal
ERROR [string.bal:(2:1,2:30)] cannot resolve module 'ballerina/stringutils'
ERROR [string.bal:(8:9,8:49)] undefined function 'equalsIgnoreCase'
ERROR [string.bal:(8:9,8:49)] undefined module 'stringutils'
error: compilation contains errors
caio@german_shepherd test % bal -v
Ballerina Swan Lake Beta 2
Language specification 2021R1
Update Tool 1.3.5
caio@german_shepherd test % sudo bal dist use slbeta2
Password:
'slbeta2' is the current active distribution version

我在 VSC 上编辑代码时看到同样的错误。 缺少什么?

ballerina/stringutils 模块随 Swan Lake Beta 1 版本一起删除。 “正则表达式”相关 API 已移至 ballerina/regex [1] 模块,其余 API 可在 langlib 字符串库 [2] 中获得。

因此我们需要按如下方式更新您的代码示例:

import ballerina/io;
 
public function main() {
    string str1 = "Comparing String";
    string str2 = "cOmpaRinG sTrinG";
    io:print("String '" + str1 + "' and '" + str2 + "' are");
    if ('string:equalsIgnoreCaseAscii(str1, str2)) {
        io:println(" equal");
    } else {
        io:println(" not equal");
    }
}

[1] https://lib.ballerina.io/ballerina/regex/latest

[2] https://lib.ballerina.io/ballerina/lang.string/latest