regex4ls-1.1.0
Changes
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 in order 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.
Whereas the SimpleRegexMatcher
is targeted to users that are new to the java.util.regex
classes, this class assumes a basic level of familiarity with the underlying Java classes.
Example Code
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
' This prints "Elvis Presley"
Print Matcher.group(2) & " " & Matcher.group(1)
End If
Replace parts of the input using capture groups:
Dim Matcher As New RegexMatcher("From 10:00 To 12:00", "From (\d\d:\d\d) To (\d\d:\d\d)", 0)
' prints "10:00-12:00"
Print Matcher.replaceAll("$1-$2")