ASP.NET 之正则表达式
转载自:http://www.regexlib.com/cheatsheet.htm?AspxAutoDetectCookieSupport=1
Metacharacters Defined |
|
|---|---|
| MChar | Definition |
| ^ | Start of a string. |
| $ | End of a string. |
| . | Any character (except \n newline) |
| | | Alternation. |
| {...} | Explicit quantifier notation. |
| [...] | Explicit set of characters to match. |
| (...) | Logical grouping of part of an expression. |
| * | 0 or more of previous expression. |
| + | 1 or more of previous expression. |
| ? | 0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string. |
| \ | Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below. |
Metacharacter Examples |
|
|---|---|
| Pattern | Sample Matches |
| ^abc | abc, abcdefg, abc123, ... |
| abc$ | abc, endsinabc, 123abc, ... |
| a.c | abc, aac, acc, adc, aec, ... |
| bill|ted | ted, bill |
| ab{2}c | abbc |
| a[bB]c | abc, aBc |
| (abc){2} | abcabc |
| ab*c | ac, abc, abbc, abbbc, ... |
| ab+c | abc, abbc, abbbc, ... |
| ab?c | ac, abc |
| a\sc | a c |
Character Escapes http://tinyurl.com/5wm3wl |
|
|---|---|
| Escaped Char | Description |
| ordinary characters | Characters other than . $ ^ { [ ( | ) ] } * + ? \ match themselves. |
| \a | Matches a bell (alarm) \u0007. |
| \b | Matches a backspace \u0008 if in a []; otherwise matches a word boundary (between \w and \W characters). |
| \t | Matches a tab \u0009. |
| \r | Matches a carriage return \u000D. |
| \v | Matches a vertical tab \u000B. |
| \f | Matches a form feed \u000C. |
| \n | Matches a new line \u000A. |
| \e | Matches an escape \u001B. |
| \040 | Matches an ASCII character as octal (up to three digits); numbers with no leading zero are backreferences if they have only one digit or if they correspond to a capturing group number. (For more information, see Backreferences.) For example, the character \040 represents a space. |
| \x20 | Matches an ASCII character using hexadecimal representation (exactly two digits). |
| \cC | Matches an ASCII control character; for example \cC is control-C. |
| \u0020 | Matches a Unicode character using a hexadecimal representation (exactly four digits). |
| \* | When followed by a character that is not recognized as an escaped character, matches that character. For example, \* is the same as \x2A. |
Character Classes http://tinyurl.com/5ck4ll |
|
|---|---|
| Char Class | Description |
| . | Matches any character except \n. If modified by the Singleline option, a period character matches any character. For more information, see Regular Expression Options. |
| [aeiou] | Matches any single character included in the specified set of characters. |
| [^aeiou] | Matches any single character not in the specified set of characters. |
| [0-9a-fA-F] | Use of a hyphen (–) allows specification of contiguous character ranges. |
| \p{name} | Matches any character in the named character class specified by {name}. Supported names are Unicode groups and block ranges. For example, Ll, Nd, Z, IsGreek, IsBoxDrawing. |
| \P{name} | Matches text not included in groups and block ranges specified in {name}. |
| \w | Matches any word character. Equivalent to the Unicode character categories [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \w is equivalent to [a-zA-Z_0-9]. |
| \W | Matches any nonword character. Equivalent to the Unicode categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \W is equivalent to [^a-zA-Z_0-9]. |
| \s | Matches any white-space character. Equivalent to the Unicode character categories [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v]. |
| \S | Matches any non-white-space character. Equivalent to the Unicode character categories [^\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \S is equivalent to [^ \f\n\r\t\v]. |
| \d | Matches any decimal digit. Equivalent to \p{Nd} for Unicode and [0-9] for non-Unicode, ECMAScript behavior. |
| \D | Matches any nondigit. Equivalent to \P{Nd} for Unicode and [^0-9] for non-Unicode, ECMAScript behavior. |
ASP.NET 之正则表达式的更多相关文章
- asp.net 验证正则表达式
基本元字符: . 任意的一个非换行字符 [] 集合匹配,匹配一个[]中出现的字符. 是在多个字符中取一个. () 调整优先级的作用. 还有一个分组的作用 | 或的意思,测试|一下. 注意,或的优先级最 ...
- asp.net 验证正则表达式 精心整理
asp.net 验证正则表达式 整数或者小数:^[0-9]+\.{0,1}[0-9]{0,2}$只能输入数字:"^[0-9]*$".只能输入n位的数字:"^\d{n}$& ...
- ASP.NET-常用正则表达式
常用正则表达式 正则: [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}", ErrorMes ...
- asp.net中正则表达式使用
一.限定符:限定符提供了一种简单方法,用于指定允许特定字符或字符集自身重复出现的次数.限定符始终引用限定符前(左边)的模式,通常是单个字符,除非使用括号创建模式组. (一)非显示限定符 1. *,描述 ...
- ASP.NET常用正则表达式
验证数字:^[0-9]*$ 验证n位的数字:^\d{n}$ 验证至少n位数字:^\d{n,}$ 验证m-n位的数字:^\d{m,n}$ 验证零和非零开头的数字:^(0|[1-9][0-9]*)$ 验证 ...
- asp.net中用正则表达式验证数据格式
这是一个验证是否为数字的例子: Regex reg = new Regex(@"^[0-9]+\.{0,1}[0-9]*$");reg.IsMatch(textBox1.T ...
- asp.net后台正则表达式验证手机号码邮箱
//如果文本中可以为空的为NO,文本中内容不为空 if (input.nullable == "no" || !isnull(input.value)) { //文本中值的类型 s ...
- (转)asp.net注册实现下一步
在asp.net中有两种容器控件,其中包括panel和placeholder控件. 使用panel控件可以对控件进行分组.一帮助组织web窗体也的内容,将控件组织在面板中,可提供有关在运行时控件应如何 ...
- js正则表达式【原】
js正则表达式 http://www.w3school.com.cn/js/js_obj_regexp.asp js常用正则表达式 我的自测样例 <HTML> <HEAD> & ...
随机推荐
- FJoi2017 1月20日模拟赛 恐狼后卫(口糊动规)
Problem 1 恐狼后卫(wolf.cpp/c/pas) [题目描述] 著名卡牌游戏<石炉传说>中有一张随从牌:恐狼后卫.恐狼后卫的能力是使得相邻随从的攻击力提高. 现在有n张恐狼后卫 ...
- 手写DAO框架(三)-数据库连接
-------前篇:手写DAO框架(二)-开发前的最后准备--------- 前言 上一篇主要是温习了一下基础知识,然后将整个项目按照模块进行了划分.因为是个人项目,一个人开发,本人采用了自底向上的开 ...
- noip模拟赛 蒜头君的排序
分析:其实就是求m个区间的逆序对个数,题目真的是明摆着让我们用莫队算法,套用树状数组就可以了. 具体怎么转移呢?如果移动R,那么对区间[l,r]有影响的是R左边的元素,我们只需要看有多少在R左边比a[ ...
- C++标准库:bitset 用法整理&&zoj 3812
转载: http://happyboy200032.blog.163.com/blog/static/46903113201291252033712/ 头文件:#include <bits/st ...
- [bzoj1613][Usaco2008 Jan]Running贝茜的晨练计划_动态规划
Running贝茜的晨练计划 bzoj-1613 Usaco-2008 Jan 题目大意:题目链接(U组题题意真的是没法概括qwq....). 注释:略. 想法:一眼dp题. 状态:dp[i][j]表 ...
- Ubuntu查看隐藏文件夹的方法
比如要查看当前用户目录下的隐藏文件夹 进入/home/jim目录,使用快捷键Ctrl+H,即可显示隐藏文件夹,如果要关闭,再次按Ctrl+H即可. GUI操作如下所示: 进入文件夹,左上角->查 ...
- gh-ost: triggerless online schema migrations:Blog by Shlomi Noach:
http://code.openark.org/blog/category/mysql https://rj03hou.github.io/mysql/gh-ost/
- spring boot日期转换
spring boot 作为微服务简易架构.拥有其自身的特点.快速搭建架构 简单 快捷.这里我只是简单的介绍下我遇到的其中的 两个问题.第一前台页面传递的时间类型 无法自动映射到Java的 Date ...
- C++对象内存分布(3) - 菱形继承(virtual)
1.前言 本篇文章的全部代码样例.假设是windows上编译执行.则使用的是visual studio 2013.假设是RHEL6.5平台(linux kernal: 2.6.32-431.el6.i ...
- Python3基础(四) 条件与循环控制
Python的流程控制语句包括:if条件语句.while循环语句.for循环语句.range函数以及break.continue.pass控制语句.这些语句在Python中的语义和在其他语言中基本是一 ...