1.0.1 1.1 regexp http://jakarta.apache.org/taglibs/regexp-1.0 Regexp Tag library

The Regexp custom tag library contains tags which can be used to perform Perl syntax regular expressions.

These tags implement the three most common Perl5 operations involving regular expressions:

As with Perl, any non-alphanumeric character can be used in lieu of the slashes.

For more information on how to use Perl syntax regular expressions you can start at the Perl Regular Expression page. http://www.perl.com/pub/doc/manual/html/pod/perlre.html

If you search the web you can find thousands of web sites documenting how to use perl regular expressions.

regexp org.apache.taglibs.regexp.RegexpTag JSP regexp Create a regular expression script variable. The body of the tag is assigned to a script variable as a regular expression. Create a regular expression script variable. id org.apache.taglibs.regexp.RegexpData true AT_BEGIN Regular Expression Bean regexp Yes No Returns the text of the regular expression. id true false Script variable id for use with standard jsp:getProperty tag and as an attribute to other tags in this tag library. Create a match regular expression scripting variable. m/test1/mi The regular expression is: ]]> text org.apache.taglibs.regexp.TextTag JSP text Create a text string script variable for use with a regexp. The body of the tag is assigned to a script variable as a text string. Create a text string script variable for use with a regexp. id org.apache.taglibs.regexp.TextData true AT_BEGIN Text String Bean text Yes No Returns the text string. id true false Script variable id for use with standard jsp:getProperty tag and as an attribute to other tags in this tag library. Create a text string scripting variable. This is a test string. The text string is: ]]> existsMatch org.apache.taglibs.regexp.ExistsMatchTag JSP existsMatch Uses a regexp to determine if a match exists in the text. Uses a regexp to determine if a match exists in the text. regexp true false Script variable id of regexp to use for match. text true false Script variable id of text to check for a match. value false false If value is set to false the existsMatch tag includes body of tag if a match does not exist. Default is true. Determine if a match can be found in a text string using a regular expression. m/test1/mi <%-- set the text to match on --%> This is a test of regular expression matching. See if a match exists...
A match was found!
A match was not found!
]]>
substitute org.apache.taglibs.regexp.SubstituteTag JSP substitute Performs a string substitution on text using a regexp. Performs a string substitution on text using a regexp. regexp true false Script variable id of regexp to use for substitute. text true false Script variable id of text to perform substitution on. Substitute "test2" for "test1" in a text string. s/test1/test2/gmi <%-- set the text to match on --%> This is test1 of regular expression substitution. Here is the text after substitution...
]]>
split org.apache.taglibs.regexp.SplitTag org.apache.taglibs.regexp.SplitTEI JSP split Implements a perl style split on the text. Implements a perl style split on the text. id org.apache.taglibs.regexp.SplitTag true NESTED Split Data Bean split Yes No Returns the string split out from text. id true false Script variable id for use with standard jsp:getProperty tag. regexp false false Script variable id of regexp to use for split. If no regexp is used the split will be done based on whitespace. text true false Script variable id of text to perform split on. limit false false Set a limit for the number of strings split out from text. First perform a split of a text string on whitespace, then perform a split on the character ','. This is test1 of a regular expression split, on whitespace, and then on a comma.

<%-- now split the text using a comma with limit of 2 --%> /,/m

]]>
match org.apache.taglibs.regexp.MatchTag org.apache.taglibs.regexp.MatchTEI JSP match Loops through each match found in a text string by a regexp. Loops through each match found in a text string by a regexp. id org.apache.taglibs.regexp.MatchTag true NESTED Match Data Bean match Yes No Returns the entire string that was matched on. preMatch Yes No Returns the string preceding the current match. postMatch Yes No Returns the string after the current match. id true false Script variable id for use with standard jsp:getProperty tag. regexp true false Script variable id of regexp to use for match. text true false Script variable id of text to perform match on. Use match to find all words in a text string that start with the letter 'i'. This is test1 of a regular expression match, on words that start with 'i' like item and index. <%-- create the match regexp "m/\si[^\s]*\s/mi" --%> m/\si[^\s]*\s/mi
                          

   Match: 
Pre Match:
Post Match:
]]> group org.apache.taglibs.regexp.GroupTag empty group Get the value of a single parenthesized group within a single match. Must be nested inside a match tag. Get the value of a single parenthesized group within a single match. number true false Parenthesised group number to get from match. Use the group tag to get the next word in a text string after a word that starts with the letter 'i'. This is test1 of a regular expression match, on words that start with 'i' like item and index, the group tag will be used to get the next word after the word starting with 'i'. <%-- create the match regexp "m/\si[^\s]*\s([^\s]+)/mi" --%> m/\si[^\s]*\s([^\s]+)/mi
                          

   Match: 
Parenthesized Group 1:
]]>