Regular Expression
It's a very elegant summary of regular expression from The AWK Programming Language.
1. The regular expression metacharacters are:
\ ^ $ . [ ] | ( ) * + ?
2. A basic regular expression is one of the following:
- a nonmetacharacter, such as A, that matches itself.
- an escape sequence that matches a special symbol: \t matches a tab.
- a quoted metacharacter, such as \*, that matches the metaqcharacter literally.
- ^, which matches the beginning of a string.
- $, which matches the end of a string.
- ., which matches any single character.
- a character class: [ABC] matches any of the characters A, B, or C. Character classes may include abbreviations: [A-Za-z] matches any single letter.
- a complemented character class: [^0-9] matches any character except a digit.
3. These operators combine regular expressions into larger ones:
- alternation: A | B matches A or B.
- concatenation: AB matches A immediately followed by B.
- closure: A* matches zero or more A's.
- positive closure: A+ matches one or more A's.
- zero or one: A? matches the null string or A.
- parentheses: (r) matches the same strings as r does.
Expression | Matches |
c | the nonmetacharacter c |
\c | escape sequence or literal character c |
^ | beginning of string |
$ | end of string |
. | any character |
[$c_1$$c_2$...] | any character in $c_1$$c_2$ |
[^$c_1$$c_2$...] | any character not in $c_1$$c_2$ |
[$c_1$-$c_2$] | any character in the range beginning with $c_1$ and ending with $c_2$ |
[^$c_1$-$c_2$] | any character not in the range $c_1$ to $c_2$ |
$r_1$|$r_2$ | any string matched by $r_1$ or $r_2$ |
($r_1$)($r_2$) | any string xy where $r_1$ matches x and $r_2$ matches y; parentheses not needed around arguments with no alternations |
(r)* | zero or more consecutive strings matched by r |
(r)+ | one or more consecutive strings matched by r |
(r)? | zero or one string matched by r parentheses not needed around basic regular expressions |
(r) | any string matched by r |
Regular Expression的更多相关文章
- [LeetCode] Regular Expression Matching 正则表达式匹配
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- myeclipse中导入js报如下错误Syntax error on token "Invalid Regular Expression Options", no accurate correc
今天在使用bootstrap的时候引入的js文件出现错误Syntax error on token "Invalid Regular Expression Options", no ...
- [LeetCode] 10. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. DP: public class Solution { publ ...
- No.010:Regular Expression Matching
问题: Implement regular expression matching with support for '.' and '*'.'.' Matches any single charac ...
- Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- 【leetcode】Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...
- 【leetcode】Regular Expression Matching (hard) ★
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- grep(Global Regular Expression Print)
.grep -iwr --color 'hellp' /home/weblogic/demo 或者 grep -iw --color 'hellp' /home/weblogic/demo/* (-i ...
- 66. Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...
- Jmeter组件4. Regular Expression Extractor
位置:Post-Processors - Regular Expression Extractor 所谓的Post-Processors直译为后处理器,意思是在域内所有Sampler执行完后才会执行, ...
随机推荐
- 更精确的判断对象类型js方法
function isArray(o) { return Object.prototype.toString.call(o) === '[object Array]'; } function isRe ...
- MySQL open_files_limit相关设置
背景: 数据库链接不上,报错: root@localhost:/var/log/mysql# mysql -uzjy -p -h192.168.1.111 --default-charact ...
- kbmmw 与extjs 的初次结合
前面写了extjs 的安装,今天写一下kbmmw 与extjs 的结合,参照delphi 产品经理marco文章 . 由于extjs 设计时要读取服务器端的数据,所以先要做一个rest 服务器. 先要 ...
- bundler简介(ruby gem)
簡介 Bundler RubyGem 是包裝.散佈Ruby程式庫的標準方式,相關文件可以參考 RubyGems Guides 的說明,或是 簡介 plugins 中的第二個例子.在使用rails ...
- 将爬取的网页数据保存到数据库时报错不能提交JPA,Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB6 \xE2...' for column 'content' at row 1
错误原因:我们可以看到错误提示中的字符0xF0 0x9F 0x98 0x84 ,这对应UTF-8编码格式中的4字节编码(UTF-8编码规范).正常的汉字一般不会超过3个字节,为什么为出现4个字节呢?实 ...
- 2019.01.24 NOIP训练 旅行(轮廓线dp)
传送门 题意简述: 给一个n∗mn*mn∗m的有障碍的网格图,问你从左上角走到左下角并覆盖所有可行格子的路径条数. 思路: 路径不是很好算. 将图改造一下,在最前面添两列,第一列全部能通过,第二列只有 ...
- ubuntu上安装win7系统(64位的)
http://www.linuxidc.com/Linux/2012-11/74195.htm deb文件在ubuntu上直接用dpkg -i xxx.deb 如果虚拟机上只显示32位,则可能是cpu ...
- RGB转换成YCbCr
clear all; close all; clc; img=imread('colorbar.jpg');%('ngc6543a.jpg'); %img=mat2gray(img); %[0,1]; ...
- linux安装源码jdk
第一步: 传输jdk到服务器上可以用xhsell,也可以用ftp 第二步:解压文件 tar -xzvf jdk-7u80-linux-x64.tar.gz 第三步:配置环境变量 输入即可 注意:修改J ...
- C++二级指针第一种内存模型(指针数组)
二级指针第一种内存模型(指针数组) 指针的输入特性:在主调函数里面分配内存,在被调用函数里面使用指针的输出特性:在被调用函数里面分配内存,主要是把运算结果甩出来 指针数组 在C语言和C++语言中,数组 ...