English 中文(简体)
定期表达,相当于25个果园,先用数字表示。
原标题:A regular expression that matches 25 chars and starts with digits

I have a text field which I need to validate using a regex. My requirement is as follow:

www.un.org/Depts/DGACM/index_french.htm

1234ABCDEFG or 123-ABCDEFG (例示)

规则:

  • The whole string is maximum 25 characters
  • The first four characters (CCCC) must be alphanumeric
  • CCCC is 4 characters exactly and can be digits or number
  • CCCC can have a dash sign as 4th character
  • NNNNNNNNNNNN can be up to 21 characters and only numbers

例如,AAAAAA<1234>是CCC的有效载体。

我的研究说明如下:

  • I will need to match numerics first
  • I will need the + char to specify to match this pattern X times
  • I will need to match letters after that for 8-9 spaces

这里有一个令人 wonder切的职位:

https://stackoverflow.com/questions/4246077/simple-problem-with-table-expression- only-datas-and-commas/4247184#4247184>

我的目标是将这一区域评价模式应用到“WinForms”的文箱Mask。

最佳回答

........

........

......yeah - 我认为你正在寻找的答案是:

^[0-9A-Za-z]{3}[0-9A-Za-z-]d{0,21}$

^               # assert beginning (not in the middle)
[0-9A-Za-z]{3}  # three characters that are: 0-9 or a-z (upper or lower)
[0-9A-Za-z-]    # one character that is: 0-9 or a-z (upper or lower) or a dash
d{0,21}        # anywhere from 0 to 21 digits
$               # assert at the end (not somewhere in the middle

如果你想将这种表述的几例相匹配,则将上述表述(具体表述)与允许分离这些数值的任何内容(s或“whitespace”)相提并论,然后使用+之四:

^([0-9A-Za-z]{3}[0-9A-Za-z-]d{0,21}s+)+$

将匹配/确定以下投入:

1234567890 AAAA123456789012345678901 GGG-123       hhh5   A1B2000000000

如果你想要其他东西的话,你就不得不提出一个更清楚的问题(在你的问题中,有许多矛盾和重复之处,使得你无法想象会混淆)。

问题回答

暂无回答




相关问题
Uncommon regular expressions [closed]

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.

regex to trap img tag, both versions

I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />

C++, Boost regex, replace value function of matched value?

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 ...

PowerShell -match operator and multiple groups

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 ...

Is it possible to negate a regular expression search?

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 ...

regex for four-digit numbers (or "default")

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" ...

热门标签