public class RegexUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RegexUtil.CheckedPatternSyntaxException
A checked version of
PatternSyntaxException . |
Modifier and Type | Method and Description |
---|---|
static String |
asRegex(String s)
Returns the argument as a
@Regex String if it is a regex,
otherwise throws an error. |
static String |
asRegex(String s,
int groups)
Returns the argument as a
@Regex(groups) String if it is a regex
with at least the given number of groups, otherwise throws an error. |
static boolean |
isRegex(char c)
Returns true if the argument is a syntactically valid regular
expression.
|
static boolean |
isRegex(String s)
Returns true if the argument is a syntactically valid regular
expression.
|
static boolean |
isRegex(String s,
int groups)
Returns true if the argument is a syntactically valid regular
expression with at least the given number of groups.
|
static String |
regexError(String s)
Returns null if the argument is a syntactically valid regular
expression.
|
static String |
regexError(String s,
int groups)
Returns null if the argument is a syntactically valid regular
expression with at least the given number of groups.
|
static PatternSyntaxException |
regexException(String s)
Returns null if the argument is a syntactically valid regular
expression.
|
static PatternSyntaxException |
regexException(String s,
int groups)
Returns null if the argument is a syntactically valid regular
expression with at least the given number of groups.
|
public static boolean isRegex(String s)
s
- is regular expressionpublic static boolean isRegex(String s, int groups)
s
- is regular expressiongroups
- is number of groups to matchpublic static boolean isRegex(char c)
c
- is a characterpublic static String regexError(String s)
s
- is regular expressionpublic static String regexError(String s, int groups)
s
- is regular expressiongroups
- is number of groups to matchpublic static PatternSyntaxException regexException(String s)
s
- is regular expressionpublic static PatternSyntaxException regexException(String s, int groups)
s
- is regular expressiongroups
- is number of groups to matchpublic static String asRegex(String s)
@Regex String
if it is a regex,
otherwise throws an error. The purpose of this method is to suppress Regex
Checker warnings. Once the the Regex Checker supports flow-sensitivity, it
should be very rarely needed.s
- is a regular expressionpublic static String asRegex(String s, int groups)
@Regex(groups) String
if it is a regex
with at least the given number of groups, otherwise throws an error. The
purpose of this method is to suppress Regex Checker warnings. Once the the
Regex Checker supports flow-sensitivity, it should be very rarely needed.s
- is a regular expressiongroups
- is number of group to matchCopyright © 2016 Apache Software Foundation. All Rights Reserved.