前6个字母应该是字符
问题描述:
文本框允许带有特殊字符连字符和空格的字母数字字符。
前6个字母应为字母...请在jquery中给我一个答案
Hi,
Textbox allowing Alpha numeric characters with special characters hyphen and space.
First 6 letters should be alphabets...please get me an answer in jquery
答
试试正则表达式:
Try a regular expression:
public static Regex regex = new Regex(
"^([a-zA-Z]{1,6}
) |([a-zA-Z] {6} [\\w-] *
)|([a-zA-Z]{6}[\\w- ]*
),
RegexOptions.IgnoreCase
| RegexOptions.Multiline
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
匹配m = regex.Match(InputText);
if (m.Success)
{
...
)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled ); Match m = regex.Match(InputText); if (m.Success) { ...