此时,最小组团就发挥作用了:正则引擎会放弃所有回溯位置。
At this point, the atomic group will kick in. The engine will discard all backtracking positions.
正则表达式可以过滤特定的位置,例如行的开始或结束,以及单词的开始和结束。
A regular expression can filter for a specific location, such as the start or end of a line and the beginning and end of a word.
当正则引擎针对最小组团进行匹配时,它会跳过组团内标记的回溯位置。
When the regex engine matches an atomic group, it will discard backtracting positions that came with all tokens inside it.
首先,我们要创建一个从文本文档中提取面积和位置概念的正则表达式规则文件。
First, we will create a regular expression rule file to extract the concepts of area and location from text documents.
创建规则文件和匹配位置和面积的正则表达式。
Creating a rule file with regular expressions for location and area.
如果在字符串的当前位置上发现一个完全匹配,那么正则表达式宣布成功。
If a complete match is found at the current position in the string, the regex declares success.
当一个正则表达式投入使用时,首先要确定目标字符串中开始搜索的位置。
When a regex is put to use, the first step is to determine the position within the target string where the search should start.
当一个特定字元匹配失败时,正则表达式将试图回溯到扫描之前的位置上,然后进入正则表达式其他可能的路径上。
When a particular token fails to match, the regex tries to backtrack to a prior point in the match attempt and follow other possible paths through the regex.
当一个正则表达式扫描目标字符串时,它从左到右逐个扫描正则表达式的组成部分,在每个位置上测试能不能找到一个匹配。
As a regex works its way through a target string, it tests whether a match can be found at each position by stepping through the components in the regex from left to right.
如果你使用正则表达式匹配一个很大字符串的一小部分,情况更为严重,正则表达式匹配失败的位置比匹配成功的位置要多得多。
This is compounded by the fact that if you're using a regex to match small parts of a large string, the regex will fail at many more positions than it will succeed.
从输入字符串中的指定起始位置开始,在该字符串中搜索正则表达式的第一个匹配项。
Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.
返回正则表达式搜索中第一个子字符串匹配项的位置。
Returns the position of the first substring match in a regular expression search.
在由指定的正则表达式模式定义的位置拆分输入字符串。
Splits the input string at the positions defined by a specified regular expression pattern.
在由指定的正则表达式模式定义的位置拆分输入字符串。
Splits the input string at the positions defined by a specified regular expression pattern.
应用推荐