Date Name Downloads
Feb 27, 2015 1.1.1 750
Sep 29, 2010 1.1.0 584
Sep 21, 2010 1.0.0 158
1.1.0
1.1.0
Sep 30, 2010
Apache License
584

This release adds the RegexMatcher class.

 
RegexMatcher combines java.util.regex.Pattern and java.util.regex.Matcher into one handy LotusScript wrapper to perform Regular Expression operations on text.
You can do repeated matches on the same string with the find() method to locate multiple occurrences of pattern matches, and you can access captured groups with the group() function. The replaceAll() and replaceFirst() methods let you replace matching parts with strings that may contain backreferences to captured parts of the original string.

In contrast to the SimpleRegexMatcher that is targeted to users new to the java.util.regex classes, this class assumes a basic level of familiarity with the underlying Java classes.
 
example code:
    ' Find name of someone who introduces himself in a James Bondish way.
    ' This example features capture groups and a backreference to the first capture group.

    Dim Matcher As New RegexMatcher("My name is Presley. Elvis Presley.", "name is (\w+). (\w+) \1.", 0)
    If Matcher.find() Then
        Print Matcher.group(2) & " " & Matcher.group(1)  ' prints "Elvis Presley"
    End If

    ' Replace parts of the input using captured groups
    Dim Matcher As New RegexMatcher("from 10:00 to 12:00", "from (\d\d:\d\d) to (\d\d:\d\d)", 0)
    Print Matcher.replaceAll("$1-$2")  ' prints "10:00-12:00"
 
How to install
Download  the file regex4ls-1.1.0.ls. Using Domino Designer, create a LotusScript library with the name  "Regular Expressions".
Copy the contents of the downloaded file into the library. Save.
In your client code (agent, another script library), reference the library with Use "Regular Expressions".