如何在Lotus Notes脚本中标记字符串

时间:2014-02-24 16:48:50

标签: lotus-notes lotusscript

我需要将一个字符串拆分成几个标记,就像下面的java代码一样:

StringTokenizer st = new StringTokenizer(mystring);
while (st.hasMoreTokens()) {
    System.out.println(st.nextToken());
}

2 个答案:

答案 0 :(得分:2)

您可以使用函数Split(myString, " "),其中第一个参数是您的字符串,第二个参数是标记分隔符。

以下是解决方案:

Dim myString = myDocument.myField(0)
Dim myTokens = Split(myString, " ")
Dim fisrtToken = myTokens(0)
Dim secondToken = myTokens(1) 

答案 1 :(得分:1)

这是我从IBM Lotus Notes 7答案中实现的代码:

Function isTokenInStr(tokenStr As String, strToSearch As String) As Boolean
    isTokenInStr = True

    Dim tokenArr As Variant
    tokenArr = Split(tokenStr, " ")
    Dim idxTokenArr As Integer 
    For idxTokenArr = LBound(tokenArr) To UBound(tokenArr) 
        Dim tokenElementStr As String
        tokenElementStr = tokenArr(idxTokenArr)
        If InStr(strToSearch, tokenElementStr) <= 0 Then
            isTokenInStr = False
            Exit For
        End If
    next
End Function