类 Perl5Compiler
- 所有已实现的接口:
PatternCompiler
Perl5Compiler and Perl5Matcher are designed with the intent that
you use a separate instance of each per thread to avoid the overhead
of both synchronization and concurrent access (e.g., a match that takes
a long time in one thread will block the progress of another thread with
a shorter match). If you want to use a single instance of each
in a concurrent program, you must appropriately protect access to
the instances with critical sections. If you want to share Perl5Pattern
instances between concurrently executing instances of Perl5Matcher, you
must compile the patterns with READ_ONLY_MASK.
- 从以下版本开始:
- 1.0
- 版本:
- @version@
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final intA mask passed as an option to thecompilemethods to indicate a compiled regular expression should be case insensitive.static final intThe default mask for thecompilemethods.static final intA mask passed as an option to thecompilemethods to indicate a compiled regular expression should be treated as a Perl5 extended pattern (i.e., a pattern using the /x modifier).static final intA mask passed as an option to thecompilemethods to indicate a compiled regular expression should treat input as having multiple lines.static final intA mask passed as an option to thecompilemethods to indicate that the resulting Perl5Pattern should be treated as a read only data structure by Perl5Matcher, making it safe to share a single Perl5Pattern instance among multiple threads without needing synchronization.static final intA mask passed as an option to thecompilemethods to indicate a compiled regular expression should treat input as being a single line. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明compile(char[] pattern) Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);compile(char[] pattern, int options) Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.static final Stringquotemeta(char[] expression) Given a character string, returns a Perl5 expression that interprets each character of the original string literally.static final StringGiven a character string, returns a Perl5 expression that interprets each character of the original string literally.
-
字段详细资料
-
DEFAULT_MASK
public static final int DEFAULT_MASKThe default mask for thecompilemethods. It is equal to 0. The default behavior is for a regular expression to be case sensitive and to not specify if it is multiline or singleline. When MULITLINE_MASK and SINGLINE_MASK are not defined, the ^, $, and . metacharacters are interpreted according to the value of isMultiline() in Perl5Matcher. The default behavior of Perl5Matcher is to treat the Perl5Pattern as though MULTILINE_MASK were enabled. If isMultiline() returns false, then the pattern is treated as though SINGLINE_MASK were set. However, compiling a pattern with the MULTILINE_MASK or SINGLELINE_MASK masks will ALWAYS override whatever behavior is specified by the setMultiline() in Perl5Matcher.- 另请参阅:
-
CASE_INSENSITIVE_MASK
public static final int CASE_INSENSITIVE_MASKA mask passed as an option to thecompilemethods to indicate a compiled regular expression should be case insensitive.- 另请参阅:
-
MULTILINE_MASK
public static final int MULTILINE_MASKA mask passed as an option to thecompilemethods to indicate a compiled regular expression should treat input as having multiple lines. This option affects the interpretation of the ^ and $ metacharacters. When this mask is used, the ^ metacharacter matches at the beginning of every line, and the $ metacharacter matches at the end of every line. Additionally the . metacharacter will not match newlines when an expression is compiled with MULTILINE_MASK , which is its default behavior.- 另请参阅:
-
SINGLELINE_MASK
public static final int SINGLELINE_MASKA mask passed as an option to thecompilemethods to indicate a compiled regular expression should treat input as being a single line. This option affects the interpretation of the ^ and $ metacharacters. When this mask is used, the ^ metacharacter matches at the beginning of the input, and the $ metacharacter matches at the end of the input. The ^ and $ metacharacters will not match at the beginning and end of lines occurring between the begnning and end of the input. Additionally, the . metacharacter will match newlines when an expression is compiled with SINGLELINE_MASK , unlike its default behavior.- 另请参阅:
-
EXTENDED_MASK
public static final int EXTENDED_MASKA mask passed as an option to thecompilemethods to indicate a compiled regular expression should be treated as a Perl5 extended pattern (i.e., a pattern using the /x modifier). This option tells the compiler to ignore whitespace that is not backslashed or within a character class. It also tells the compiler to treat the # character as a metacharacter introducing a comment as in Perl. In other words, the # character will comment out any text in the regular expression between it and the next newline. The intent of this option is to allow you to divide your patterns into more readable parts. It is provided to maintain compatibility with Perl5 regular expressions, although it will not often make sense to use it in Java.- 另请参阅:
-
READ_ONLY_MASK
public static final int READ_ONLY_MASKA mask passed as an option to thecompilemethods to indicate that the resulting Perl5Pattern should be treated as a read only data structure by Perl5Matcher, making it safe to share a single Perl5Pattern instance among multiple threads without needing synchronization. Without this option, Perl5Matcher reserves the right to store heuristic or other information in Perl5Pattern that might accelerate future matches. When you use this option, Perl5Matcher will not store or modify any information in a Perl5Pattern. Use this option when you want to share a Perl5Pattern instance among multiple threads using different Perl5Matcher instances.- 另请参阅:
-
-
构造器详细资料
-
Perl5Compiler
public Perl5Compiler()
-
-
方法详细资料
-
quotemeta
Given a character string, returns a Perl5 expression that interprets each character of the original string literally. In other words, all special metacharacters are quoted/escaped. This method is useful for converting user input meant for literal interpretation into a safe regular expression representing the literal input.In effect, this method is the analog of the Perl5 quotemeta() builtin method.
- 参数:
expression- The expression to convert.- 返回:
- A String containing a Perl5 regular expression corresponding to a literal interpretation of the pattern.
-
quotemeta
Given a character string, returns a Perl5 expression that interprets each character of the original string literally. In other words, all special metacharacters are quoted/escaped. This method is useful for converting user input meant for literal interpretation into a safe regular expression representing the literal input.In effect, this method is the analog of the Perl5 quotemeta() builtin method.
- 参数:
expression- The pattern to convert.- 返回:
- A String containing a Perl5 regular expression corresponding to a literal interpretation of the pattern.
-
compile
Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching. Please see the user's guide for more information about Perl5 regular expressions.- 指定者:
compile在接口中PatternCompiler- 参数:
pattern- A Perl5 regular expression to compile.options- A set of flags giving the compiler instructions on how to treat the regular expression. The flags are a logical OR of any number of the five MASK constants. For example:regex = compiler.compile(pattern, Perl5Compiler. CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);This says to compile the pattern so that it treats input as consisting of multiple lines and to perform matches in a case insensitive manner.- 返回:
- A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably casted to a Perl5Pattern.
- 抛出:
MalformedPatternException- If the compiled expression is not a valid Perl5 regular expression.
-
compile
Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);- 指定者:
compile在接口中PatternCompiler- 参数:
pattern- A regular expression to compile.- 返回:
- A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably casted to a Perl5Pattern.
- 抛出:
MalformedPatternException- If the compiled expression is not a valid Perl5 regular expression.
-
compile
Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);- 指定者:
compile在接口中PatternCompiler- 参数:
pattern- A regular expression to compile.- 返回:
- A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably casted to a Perl5Pattern.
- 抛出:
MalformedPatternException- If the compiled expression is not a valid Perl5 regular expression.
-
compile
Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching. Please see the user's guide for more information about Perl5 regular expressions.- 指定者:
compile在接口中PatternCompiler- 参数:
pattern- A Perl5 regular expression to compile.options- A set of flags giving the compiler instructions on how to treat the regular expression. The flags are a logical OR of any number of the five MASK constants. For example:regex = compiler.compile("^\\w+\\d+$", Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);This says to compile the pattern so that it treats input as consisting of multiple lines and to perform matches in a case insensitive manner.- 返回:
- A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably casted to a Perl5Pattern.
- 抛出:
MalformedPatternException- If the compiled expression is not a valid Perl5 regular expression.
-