English 中文(简体)
Regex c#, 涉及数字和空间
原标题:Regex c# involving digit and spaces
  • 时间:2012-01-13 22:02:41
  •  标签:
  • c#
  • .net
  • regex

The following Regex do?

    d{1,3}.?d{0,3}s[0-9a-zA-Z. -]{4,40} 

我的理解是,数字是多少,但做了1,3次。

如果有人能够进一步解释,将不胜感激。

最佳回答

{n,m} is a finntifier, which means “atless n time, at most m time”。 与所有qu抗体一样,它因违约而处于贪 gr状态,而支持它们的reg和 possess({n,m}?{n,m}+。 ——不幸的是,网络支持前者,但不支持后者。

如未具体指明<代码>n,则该编码为0;如未具体说明<代码>m,则该编码为定数。

也就是说,你可以“重写”传统的<代码>*,+?

  • * is {0,};
  • + is {1,};
  • ? is {0,1}.

(note: I think the . in .? was meant to be a literal dot, which means it should be escaped, that is .?; the dot in a regex means "any character", except in a character class.)

条例本身:

d{1,3}        # match a digit, one to three times, followed by
.?             # any character, 0 or one time (see my remark), followed by
d{0,3}        # a digit, zero to three times, followed by
s             # a space character, followed by
[0-9a-zA-Z. -] # a digit, or any letter, or a dot, or a space, or a hyphen,
{4,40}         # 4 to 40 times

最后,应当指出,d in .NET Language is not limit un to 0-9, 它可以与统法协会的其他编码数字相匹配。

编辑:考虑到@AlanMoore的评述,固定的监管机构将:

d{1,3}(.d{1,3})?s[0-9a-zA-Z. -]{4,40}

Maybe this regex should be anchored, too... But this is a guess only.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签