This project enables LotusScript developers to use Regular Expressions in their code.
It does so by providing a script library with simple wrappers around Java classes that are invoked by LS2J.
The wrapper classes behave like native LotusScript classes. All the clumsiness of JNI declarations that comes with using LS2J is abstracted away from the user.
SimpleRegexMatcher can determine whether a text matches a pattern.
In case of a match it gives you access to the matching part of the original text via its Match property.
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
find() to locate multiple occurrences of pattern matches, and you can access captured groups with
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,
RegexMatcher assumes a basic level of familiarity with the underlying Java classes.
The Regular Expressions used in this class follow java.util.regex.Pattern syntax as described here.
Intended audience: LotusScript developers.
note: in these examples,
&stands for the ampersand character, which OpenNTF automatically converts to the corresponding HTML entity when displaying pages.
Search for an agent with licence to kill.
Dim Matcher As New SimpleRegexMatcher
If Matcher.matches("James Bond is agent 007.", "\b00\d\b") Then
' This prints "found agent #007"
Print "found agent #" & Matcher.Match
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)
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"