regular expression, grep (python, linux)
>>> import re
- . (dot) - a single character.
- ? - the preceding character matches 0 or 1 times only.
- * - the preceding character matches 0 or more times.
- + - the preceding character matches 1 or more times.
- {n} - the preceding character matches exactly n times.
- {n,m} - the preceding character matches at least n times and not more than m times.
- [agd] - the character is one of those included within the square brackets.
- [^agd] - the character is not one of those included within the square brackets.
- [c-f] - the dash within the square brackets operates as a range. In this case it means either the letters c, d, e or f.
- () - allows us to group several characters to behave as one.
- | (pipe symbol) - the logical OR operation.
- ^ - matches the beginning of the line.
- $ - matches the end of the line.
- \s - matches anything which is considered whitespace. This could be a space, tab, line break etc.
- \S - matches the opposite of \s, that is anything which is not considered whitespace.
- \d - matches anything which is considered a digit. ie 0 - 9 (It is effectively a shortcut for [0-9]).
- \D - matches the opposite of \d, that is anything which is not considered a digit.
- \w - matches anything which is considered a word character. That is [A-Za-z0-9_]. Note the inclusion of the underscore character '_'. This is because in programming and other areas we regulaly use the underscore as part of, say, a variable or function name.
- \W - matches the opposite of \w, that is anything which is not considered a word character.
- Tab - represented in regular expressions as \t
- Carriage return - represented in regular expressions as \r
- Line feed (or newline) - represented in regular expressions as \n
- Windows - uses the sequence \r\n (in that order)
- Mac OS (version 9 and below) - uses the sequence \r
- Unix/Linux and OSX - uses the sequence \n
- \< - represents the beginning of a word.
- \> - represents the end of a word.
- \b - represents either the beginning or end of a word.
- ( )Group part of the regular expression.\1 \2 etcRefer to something matched by a previous grouping.|Match what is on either the left or right of the pipe symbol.(?=x)Positive lookahead.(?!x)Negative lookahead.(?<=x)Positive lookbehind.(?<!x)Negative lookbehind.
regular expression, grep (python, linux)的更多相关文章
- [leetcode]Regular Expression Matching @ Python
原题地址:https://oj.leetcode.com/problems/regular-expression-matching/ 题意: Implement regular expression ...
- grep(Global Regular Expression Print)
.grep -iwr --color 'hellp' /home/weblogic/demo 或者 grep -iw --color 'hellp' /home/weblogic/demo/* (-i ...
- Python中的正则表达式regular expression
1 match = re.search(pat,str) If the search is successful, search() returns a match object or None o ...
- Python正则表达式Regular Expression基本用法
资料来源:http://blog.csdn.net/whycadi/article/details/2011046 直接从网上资料转载过来,作为自己的参考.这个写的很清楚.先拿来看看. 1.正则表 ...
- python(4): regular expression正则表达式/re库/爬虫基础
python 获取网络数据也很方便 抓取 requests 第三方库适合做中小型网络爬虫的开发, 大型的爬虫需要用到 scrapy 框架 解析 BeautifulSoup 库, re 模块 (一) r ...
- 正则表达式-使用说明Regular Expression How To (Perl, Python, etc)
notepad++ wiki about regular expression 正则表达式-使用说明Regular Expression How To (Perl, Python, etc) http ...
- Python 模块 re (Regular Expression)
使用 Python 模块 re 实现解析小工具 概要 在开发过程中发现,Python 模块 re(Regular Expression)是一个很有价值并且非常强大的文本解析工具,因而想要分享一下此 ...
- python learning Regular Expression.py
# 正则表达式,又称规则表达式.(英语:Regular Expression,在代码中常简写为regex.regexp或RE),计算机科学的一个概念.正则表达式通常被用来检索.替换那些符合某个模式(规 ...
- Python -- 正则表达式 regular expression
正则表达式(regular expression) 根据其英文翻译,re模块 作用:用来匹配字符串. 在Python中,正则表达式是特殊的字符序列,检查一个字符串是否与某种模式匹配. 设计思想:用一 ...
随机推荐
- 36-OLED显示实验
1.OLED原理 有四种工作模式 先把片选拉低,如果是写的话,把RD拉高,在WR的上升沿写数据到数据线上,DC决定是数据还是命令.读类似了. 2.程序显示原理 3.代码 4.自己写代码 http:// ...
- Excel打开图片
=HYPERLINK("D:\固定资产图片\"&C2&".jpg",C2)
- <%@ include file=""%>与<jsp:include page=""/>区别(转)
http://www.iteye.com/topic/312500/ 我们都知道在jsp中include有两种形式,分别是Include指令:<%@ include file="&qu ...
- 多线程学习-基础(一)Thread和Runnable实现多线程
很久没记录一些技术学习过程了,这周周五的时候偶尔打开“博客园”,忽然让我产生一种重拾记录学习过程的想法,记录下学习研究过程的一点一滴,我相信,慢慢地就进步了!最近想学习一下多线程高并发,但是多线程在实 ...
- ASP.NET常用数据绑定控件优劣总结
本文的初衷在于对Asp.net常用数据绑定控件进行一个概览性的总结,主要分析各种数据绑定控件各自的优缺点,以便在实际的开发中选用合适的控件进行数据绑定,以提高开发效率. 因为这些数据绑定控件大部分都已 ...
- for循环 break
for (int i = 1; i <= 8;i++) {} for (int i=10; i>=1;i--) i的起始值是10 着次递减 for(){}嵌套放便控制行列的长短 break ...
- @RequestMapping与@ModelAttribute 套路
新接触一个项目,使用了大量注解: 在通过请求路径查看时一直找不到页面的跳转,再查看了文件内所有方法与注解后才找到对应的路径,特此记下: @ModelAttribute("totalfinal ...
- jQuery的Validate插件
http://www.runoob.com/jquery/jquery-plugin-validate.html 项目中的:: $(function () { $('#createDepartment ...
- 基于docker虚拟化创建hadoop集群
最近想用hadoop做一个测试,与性能无关的测试,但是可与屌丝的命,手头没有太多机器,也租不起云主机.这里使用docker进行虚拟化,并搭建hadoop集群,在这里将过程记录如下. 首先安装docke ...
- Docker 三架马车
1. Docker Compose 我们前面的课程讲到过两个容器之间通过名字进行互联互通的话可以通过link参数来关联,这种做法比较麻烦,更好的方式是使用Docker Compose来定义一个 YAM ...