3

I need to split a string into several tokens just like the java code below:

StringTokenizer st = new StringTokenizer(mystring);
while (st.hasMoreTokens()) {
    System.out.println(st.nextToken());
}
Rafael Borja
  • 4,487
  • 7
  • 29
  • 33

2 Answers2

3

You can use the function Split(myString, " "), where the first parameter is your string and the second one the token delimiter.

Here's the solution:

Dim myString = myDocument.myField(0)
Dim myTokens = Split(myString, " ")
Dim fisrtToken = myTokens(0)
Dim secondToken = myTokens(1) 
Rafael Borja
  • 4,487
  • 7
  • 29
  • 33
  • 1
    dim index as integer for index=lbound(myTokens) to ubound(myTokens) print myTokens(indeX) end for – umeli Feb 26 '14 at 09:19
1

Here's the code I implemented from the answers around for 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
Michael Fayad
  • 1,216
  • 1
  • 17
  • 38