Jakarta REGEXP Taglib Example


<%@ taglib uri="http://jakarta.apache.org/taglibs/regexp-1.0" prefix="rx" %>

Create the match regexp "m/test1/mi"
m/test1/mi
Setting the text to match on to

This is a
test of regular expression matching.
This is a test of regular expression matching.
Seeing if a match exists...
A match was found!
A match was not found!

Setting the text to match on to
This is
test1 of regular expression matching,
I hope you like it, and will use it.
This is test1 of regular expression matching, I hope you like it, and will use it.
Seeing if a match exists...
A match was found!
A match was not found!

Create the substition regexp "s/test1/test2/gmi"
s/test1/test2/gmi
Here is the last text after substitution

Now lets split the above text on whitespace
/,/m
Now lets split the above text on a ","

Now lets split the above text on a ",", but limit it to 2 items

Create the match regexp "m/\si[^\s]*\s([^\s]+)/mi" to match on any word starting with "i" and get the next word.
m/\si[^\s]*\s([^\s]+)/mi

  Match: 
    Parenthesized Group 1: 
    PreMatch: 
    PostMatch: