Can I make a regex match all characters up to; except \;?
我可以做一个正则表达式匹配所有字符到;除\;?
Each regex is represented by a match element.
每个正则表达式都由一个匹配元素表示。
A higher number means that an attempt to match the regex starting at the end of the previous match is done until all matches specified are found. Only the last match is returned.
更高的数字意味着在以前匹配结束后开始尝试匹配regex的操作将一直持续到发现所有指定的匹配,然后仅返回最后的匹配项。
If the regex engine is given the word 'engineering', it will correctly match 'engineer'. The next word boundary, \ b, will not match.
如果把“engineering”拿去匹配,正则引擎会先匹配到“engineer”,但接下来就遇到了字词边界,b,所以匹配不成功。
Here's the rule to follow: count the number of left parentheses from the beginning of the regex - the count is the index to the match array.
下面是需要遵循的规则:从regex的开头开始计算左括号的数目——该计数是匹配数组的索引。
In the first versions of XI, you would specify the regex through a pattern attribute associated to the match element.
在XI的第一个版本中,您应该通过与匹配元素相关的模式属性指定正则表达式。
Given a regex and a datum, a regex engine yields whether the datum matches a pattern and, if a match was found, what matched.
给定一个正则表达式和数据,正则表达式引擎将得到数据是否匹配模式及匹配内容(如果找到匹配)等结果。
If a complete match is found at the current position in the string, the regex declares success.
如果在字符串的当前位置上发现一个完全匹配,那么正则表达式宣布成功。
If you omit it, your regex would match any string that begins with a letter, contains two to nine alphanumeric characters, and any number of any other characters.
如果忽略掉它,regex将匹配开头为字母、包含2至9个字母数字字符以及任意数目的任何其他字符的所有字符串。
However, since the regex must be able to match whitespace-only strings, the entire capturing group is made optional by adding a trailing question mark quantifier.
然而,由于正则表达式必需能够匹配全部由空格组成的字符串,整个捕获组通过尾随一个?量词而成为可选组。
You have to include the character or characters between the words, otherwise the regex fails to find a match.
在单词之间必须包括这一(或这些)字符,否则该regex将无法找到匹配。
The key to preventing this kind of problem is to make sure that two parts of a regex cannot match the same part of a string.
预防此类问题的关键是确保正则表达式的两个部分不能对字符串的同一部分进行匹配。
More often, though, a regex is used to prove a match and to extract information about the match.
但是,regex更常用于检验匹配和提取关于匹配的信息。
But if the chosen option can't find a match or anything later in the regex fails, the regex backtracks to the last decision point where untried options remain and chooses one.
但是如果所选择的方案未能发现相应匹配,或者后来的匹配也失败了,正则表达式将回溯到最后一个决策点,然后在剩余的选项中选择一个。
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 an example, let's say you want to match HTML tags, and you come up with the following regex.
例如,假设你想匹配的HTML标签,使用了下面的正则表达式。
The regex must try all of these permutations before giving up on the match attempt.
正则表达式在最终放弃匹配之前必须尝试所有的排列组合。
By matching more than one character at a time, you'd let the regex skip many unnecessary steps on the way to a successful match.
你是对的,通过每次匹配多个字符,你让正则表达式在成功匹配的过程中跳过许多不必要的步骤。
You might be surprised to learn, though, that none of the big browsers are currently smart enough to realize in advance that this regex can match only at the end of the string.
你可能觉得很奇怪,虽说当前没有哪个浏览器聪明到这个程度,能够意识到这个正则表达式只能匹配字符串的末尾。
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.
如果你使用正则表达式匹配一个很大字符串的一小部分,情况更为严重,正则表达式匹配失败的位置比匹配成功的位置要多得多。
REGEX - How to match set of string with at least one special character anywhere?
正则表达式-如何与至少一个特殊字符的字符串集的地方?
If all possible paths through the regex have been attempted but a match was not found, the regex engine goes back to step 2 to try again at the next character in the string.
如果正则表达式的所有可能路径都尝试过了,但是没有成功地匹配,那么正则表达式引擎回到第二步,从字符串的下一个字符重新尝试。
It does, and the regex is also able to match the following space character.
确实匹配,然后正则表达式又匹配了后面的空格。
If not, the regex continues searching for a match until it finally makes its way through the entire string.
如果不是这样的话,正则表达式就继续搜索匹配,直到穿越了整个字符串。
If not, the regex continues searching for a match until it finally makes its way through the entire string.
如果不是这样的话,正则表达式就继续搜索匹配,直到穿越了整个字符串。
应用推荐