请协助适当的Ref对2封信进行匹配,随后将6个整数合并在一起。
These would be valid:
RJ123456
PY654321
DD321234
These would not
DDD12345
12DDD123
请协助适当的Ref对2封信进行匹配,随后将6个整数合并在一起。
These would be valid:
RJ123456
PY654321
DD321234
These would not
DDD12345
12DDD123
[a-zA-Z]{2}d{6}
[a-zA-Z]{2}
means two letters
d{6}
means 6 digits
If you want only uppercase letters, then:
[A-Z]{2}d{6}
你可以尝试这样的事情:
[a-zA-Z]{2}[0-9]{6}
这里的表述是:
[a-zA-Z] # Match a single character present in the list below
# A character in the range between “a” and “z”
# A character in the range between “A” and “Z”
{2} # Exactly 2 times
[0-9] # Match a single character in the range between “0” and “9”
{6} # Exactly 6 times
这将在某个主题中与任何地方相匹配。 如果你需要围绕这一主题划定界限,你可以做以下两种工作:
^[a-zA-Z]{2}[0-9]{6}$
以确保整个主题一致。 一、导 言
or
[a-zA-Z]{2}[0-9]{6}
http://www.google.co.uk/url?sa=t&rct=j&q=word%20boundary%20regex&source=web&cd=1&sqi=2&ved=0CCwQFjA&url=http://www. norm-expressions.info/word约束aries.html&ei=Pv2iT5zYmjiQfyq-Wpw&usg=AFQjprelk=
如“Phrogz”所指出的,你可以通过替换<代码>[0-9]<>>>>而使这一表述变得更可怕,如其他一些答复所示。
[a-zA-Z]{2}d{6}
我取决于你使用什么reg语,但非正式的是:
[:alpha:][:alpha:][:digit:][:digit:][:digit:][:digit:][:digit:][:digit:]
where [:alpha:] = [a-zA-Z]
and [:digit:] = [0-9]
如果你使用允许明确重复的常规语言,那么,就象:
[:alpha:]{2}[:digit:]{6}
正确的辛迪加取决于你所使用的特定语言,但这是想法。
Everything you need here can be found in this quickstart guide.
A straightforward solution would be [A-Za-z][A-Za-z]dddddd
or [A-Za-z]{2}d{6}
.
如果你只接受英文大写字母,则将<代码>[A-Za-z]改为[A-Z]
。
根据您的reg夫的支持,我可以使用:
[A-Z]{2}d{6} # Ensure there are "word boundaries" on either side, or
(?<![A-Z])[A-Z]{2}d{6}(?!d) # Ensure there isn t a uppercase letter before
# and that there is not a digit after
Recently I discovered two amazing regular expression features: ?: and ?!. I was curious of other neat regex features. So maybe you would like to share some tricky regular expressions.
I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />
How do I, using preg_replace, replace more than one underscore with just one underscore?
I was trying to write a regexp to replace all occurrences of with unless the is already preceeded immediately by a . I m doing this in Ruby 1.8.6 which doesn t support look behind in ...
Specifically, I have an array of strings called val, and want to replace all instances of "%{n}%" in the input with val[n]. More generally, I want the replace value to be a function of the match ...
I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...
I m building a lexical analysis engine in c#. For the most part it is done and works quite well. One of the features of my lexer is that it allows any user to input their own regular expressions. This ...
I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...