org.xwiki.velocity.tools
Class RegexTool
java.lang.Object
org.xwiki.velocity.tools.RegexTool
public class RegexTool
- extends Object
Velocity Tool offering various Regex-based APIs to make it easy to manipulate regular expressions from Velocity.
- Since:
- 2.0RC2
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RegexTool
public RegexTool()
find
public List<RegexTool.RegexResult> find(String content,
String regex)
- Parameters:
content
- the content to parseregex
- the regex to look for in the passed content
- Returns:
- empty list if the passed regex doesn't match the content or several
RegexTool.RegexResult
objects
containing the matched position and matched content for all capturing groups, the first group
representing the whole . The first object is represents the entire pattern
compile
public Pattern compile(String regex)
- Compiles a regular expression into a java
Pattern
object.
- Parameters:
regex
- the textual representation of the regular expression
- Returns:
- the
Pattern
object corresponding to the regular expression, or null
if the expression is
invalid - Since:
- 2.3M1
quote
public String quote(String s)
- Returns a literal pattern
String
for the specified String
.
This method produces a String
that can be used to create a Pattern
that would match the
string s
as if it were a literal pattern.
Metacharacters or escape sequences in the input sequence will be given no special meaning.
- Parameters:
s
- The string to be literalized
- Returns:
- A literal string replacement
- Since:
- 2.4M2