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中,正则表达式是特殊的字符序列,检查一个字符串是否与某种模式匹配. 设计思想:用一 ...
随机推荐
- Mat表达式
利用C++中的运算符重载,Opencv2中引入了Mat运算表达式.这一新特点使得使用c++进行编程时,就如同写Matlab脚本. 例如: 如果矩阵A和B大小相同,则可以使用如下表达式: C=A+B+1 ...
- HTML中关于url、scr、href的区别
URL是什么 URL:Uniform Resource Locators(统一资源定位器)的简写,Web浏览器通过URL从Web服务器请求页面. url不是属性,src和href是属性,src用于替换 ...
- 使用Maven搭建SSM框架(Eclipse)
今天学习一下使用Maven搭建SSM框架,以前都是用别人配置好的框架写代码,今天试试自己配置一下SSM框架. 这里我的参数是Windows7 64位,tomcat9,eclipse-jee-neon- ...
- spark sql使用sequoiadb作为数据源
目前没有实现,理一下思路,有3中途径: 1:spark core可以使用sequoiadb最为数据源,那么是否spark sql可以直接操作sequoiadb. 2: spark sql支持Hive, ...
- 多线程学习-基础(六)分析wait()-notify()-notifyAll()
一.理解wait()-notify()-notifyAll()obj.wait()与obj.notify()必须要与synchronized(Obj)一起使用,也就是wait,notify是针对已经获 ...
- jQuery 插件开发——PopupLayer(弹出层)
导读:上次写了一篇关于GridView的插件开发方法,上几天由于工作需要,花了一天左右的事件封装了popupLayer(弹出层)插件.今天有时间就记录一下自己的开发思想与大家分享下,同时也算是对这段时 ...
- Grideview总结
http://www.cnblogs.com/sufei/archive/2010/03/27/1698590.html
- C# console application executing macro function
C#控制台应用程序,执行或运行Office的宏函数,程序如下: 应用例子:
- 动态合并Repeater控件数据列
前天Insus.NET实现<动态合并GridView数据行DataRow的列>.今天再玩玩Repeater控件,功能也是动态合并某列栏位.Repeater控件跟GridView控件一样集成 ...
- linux linux系统的安装及使用
linux linux系统的安装及使用 一.linux系统中安装vm-tools工具: 步骤: 1.在vmware workstation软件中:虚拟机-安装vmware-tools-状态栏会提示- ...