java.util.regex
Class Matcher
java.lang.Object
java.util.regex.Matcher
All Implemented Interfaces:
MatchResult
public final class Matcher
extends Object
implements MatchResult
An engine that performs(执行) match operations(操作)on a
character sequence
byinterpreting(解释)a
Pattern
.
执行匹配操作在一个字符序列通过pattern
A matcher is created from a pattern by invoking(调用)the pattern'smatcher
method. Once created, a matcher can be
used to perform three different kinds of matchoperations:
一个matcher被创建时从一个pattern调用这pattern的matcher方法,一旦被创建,
matcher能被用执行三种不同的匹配操作
-
The
matches
method attempts to match the entire(全部)input sequence against the pattern.
-
The
lookingAt
method attempts to match the input sequence, starting at the beginning, against the pattern.
-
The
find
method scans the input sequence looking for the next subsequence that matches the pattern.
matches
方法有顺序的匹配所有
lookingAt
方法是匹配从开始到结束的匹配
find
方法有顺序的找下一个匹配
Each of these methods returns a boolean indicating(指示)success or failure. More information about a successful match can beobtained(获得)byquerying(询问)the state of the matcher.
三个方法返回的是一个boolean表示成功或者失败。能获得许多关于成功匹配的信息
通过询问matcher
A matcher finds matches in a subset(子集) of its input called theregion(范围). By default, theregion
contains all of the matcher's input. The region can bemodified(修改)via(通过)theregion
method and queried via theregionStart
andregionEnd
methods. The way that the regionboundaries(周围)interact(交换)with some patternconstructs(建筑,样式)can be changed. SeeuseAnchoringBounds
anduseTransparentBounds
for more details.
matcher匹配的子集在它中叫区域,默认情况下,这区域包含了所有匹配的数据。
区域能被修改用region方法和查询可以通过regionStart和regionEnd
方法。
这区域的周围可以交换用一些patter样式能被改变。查看useAnchoringBounds
和useTransparentBounds更多的信息。
This class also defines(规定)methods for replacing matched subsequences with new strings whose contents can, ifdesired(渴望,想要的), be computed from the match result. TheappendReplacement
andappendTail
methods can be used in
tandem(串联)in order to collect the result into anexisting(现有)string buffer, or the more convenientreplaceAll
method can be used to create
a string in which every matching subsequence in the input sequence is replaced.
这个类规定许多方法有序替换字符串用新的字符串。如果需要的话,matcher结果计算
appendReplacement
和appendTail
方法能被用来串联成集合在一个现有的字符缓冲区
更方便的replaceAll
方法能被用创建一个字符串,被替换的在每个有序匹配。
The explicit state of a matcher includes the start and end indices of the most recent successful match. It also includes the start and end indices of the input subsequence captured by eachcapturing
group in the pattern as well as a total count of such subsequences. As a convenience, methods are also provided for returning these captured subsequences in string form.
匹配的成功状态包含了开始和结束的索引,它还包含了开始和结束
The explicit(明确的)state of a matcher is
initially(最初的)undefined; attempting(尝试)to query any part of it before a successful match willcause(引起)anIllegalStateException
to be thrown. The explicit state of a matcher isrecomputed(重新)by every match operation.
The implicit(绝对的)state of a matcher includes the input character sequence as well as theappend position, which isinitially zero and is updated by theappendReplacement
method.
这matcher最初是未定义的,尝试查询任何部分在匹配成功之前将引起一个IllegalStateException
抛出
明确的匹配是重新每个匹配操作。
matcher的绝对匹配包含字符串顺序输入和追加位子。最初由0开始和更新通过appendReplacement
方法。
A matcher may be reset explicitly(明白的,正确的)by invoking itsreset()
method or, if a new input sequence isdesired(想得到), itsreset(CharSequence)
method. Resetting a matcher discards(不使用)its explicit state information and sets the append position to zero.
Instances of this class are not safe for use by multiple concurrent threads.
mathcher匹配正确通过它的reset方法或者,假如需要一个新的输入序列,
它的reset(CharSequence)方法,重新的一个匹配将丢弃和设置这位子为0
这个类的实例不是安全的通过多线程使用。
分享到:
相关推荐
template <class InputIterator1, class InputIterator2, class BinaryPredicate> pair, InputIterator2> mismatch (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate ...
您还可以使用ng generate directive|pipe|service|class|guard|interface|enum|module 。 建造 运行ng build来构建项目。 构建工件将存储在dist/目录中。 使用--prod标志进行生产构建。 运行单元测试 运行ng test以...
To search within streams or files (of virtually unlimited size), use one of the specially optimized TDIRegExSearchStream class descendents. Replacements on full and partial matches / substrings. ...
To search within streams or files (of virtually unlimited size), use one of the specially optimized TDIRegExSearchStream class descendents. Replacements on full and partial matches / substrings. ...
To search within streams or files (of virtually unlimited size), use one of the specially optimized TDIRegExSearchStream class descendents. Replacements on full and partial matches / substrings. ...
const { findMatches } = require ( 'find-css-matches' ) const styles = ` div#target { padding: 40px; } div#not-being-used { opacity: .5; } .class-that-could-exist #target { font-size: 18px; }...
Overview Package Class Tree Deprecated Index Help PREV NEXT FRAMES NO FRAMES A B C D E F G H I J L P R S U V -------------------------------------------------------------------------------- A ...
/* * tokenize方法是选择... * group[0][1] = {type:'CLASS',value:'.class',matches:match} * group[1][0] = {type:'TAG',value:'span',matches:match} * 由上述结果可以看出,groups的每一个元素以逗号分隔的选择
7 Core Experiment CE-Shape-1 is a popular database for shape matching evaluation consisting of 70 shape categories, where each category is represented by 20 different images with high intra-class ...
/post/:id(\.:format) => matches /post/33, /post/33.json .. /post/33.xml 示例代码: require 'vendor/autoload.php'; // use PCRE patterns you need Pux\PatternCompiler class. use Pux\...
jQuery1.2 API 中文版折叠展开折叠全部展开全部 英文说明 核心jQuery 核心函数 jQuery(expression,[context]) jQuery(expression,[context]) 这个函数接收一个包含 CSS 选择器的字符串,然后用这个字符串去匹配一组...
-- Define a basic pattern that matches / "/": => profile_url = @url_for "profile", name: "leafo" @html -> h2 "Welcome!" text "Go to my " a href: profile_url, ...
A table driven character comparison approach is used to make it easy to choose between case sensitive and case insensitive matches. WuManber.h: header file WuManber.cpp: class implementation Main...
new class of local image features. The features are invariant to image scaling, translation, and rotation, and partially invariant to illumination changes and affine or 3D projection. These features ...
(kps,features)=sift.detectAndCompute(image,None)#这里的kps是一个特征点对象,<class 'list'>,属性有.pt关键点坐标 #.angle关键点方向 .response响应强度 .size该点的直径大小 kps = np.float32([kp.pt for ...
A key tenet of Script# is to generate JavaScript that is readable, understandable, and closely matches the originating source wherever possible. The goal is not to abstract away the underlying script...
Matches, Groups, and Captures 234 Summary 237 Chapter 9: Collections 239 Examining Groups of Objects 239 Array Lists 240 Collections 241 Dictionaries 245 Summary 256 Chapter 10: Reflection 257 Custom ...
Test: Debug Here and Debug Till End triggered an "invalid class typecast" error if the test subject editor was in hexadecimal mode. Test: If a regular expression contained an inverted range with a \...
ArrayList a = ClassLibrary1.Class1.GetString(reg, str); for (int i = 0; i ; i++) { string[] arr = (string[])a[i]; Result r = new Result(); r.Value1 = arr[0]; r.Value2 = ClassLibrary1....
16.2 Exact solution: a plane wave interference pattern matches the waveguide boundary conditions 196 16.3 Waveguide vs. coax for low-loss power transmission 201 16.4 Waveguide impedance 201 16.5 ...