正则学习笔记

定义

简单的来说就是用在字符串的处理上面的一项表达式。

基础表达式

<font color=red>注意:</font>不同的环境语系会导致不同选取结果,这里以LANG=C为例子。
常用特殊符号:

特殊符号 代表意义
[:alnum:] 代表英文大小写字符以及数字
[:digit:] 代表数字
[:alpha:] 代表英文大小写
[:blank:] 代表空格键和tab键
[:lower:] 代表小写字符
[:upper:] 代表大写字符
[:xdigit:] 代表十六进制的数字类型
这里的可以用[a-z],[0-9]替代

基础命令
grep - [acinv]
i:不区分大小写
n:列出行号
v:取反操作
c:计算找到字符串的次数
a:将binary文件以text文件的方式查找数据
为方便下面的操作,我们需将系统环境设置为LANG=C,以及在~/.bashrc内加入alias grep='grep -color=auto',最后source ~/.bashrc即可。
练习文件摸我
Of course you can use command to get this file.

wget http://linux.vbird.org/linux_basic/0330regularex/regular_express.tx

And you can see what's inside by using cat command

➜  Desktop cat regular_express.txt 
"Open Source" is a good mechanism to develop programs.
apple is my favorite food.
Football game is not use feet only.
this dress doesn't fit me.
However, this dress is about $ 3183 dollars.
GNU is free air not free beer.
Her hair is very beauty.
I can't finish the test.
Oh! The soup taste good.
motorcycle is cheap than car.
This window is clear.
the symbol '*' is represented as start.
Oh! My god!
The gd software is a library for drafting programs.
You are the best is mean you are the no. 1.
The world <Happy> is the same with "glad".
I like dog.
google is the best tools for search keyword.
goooooogle yes!
go! go! Let's go.
# I am VBird


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 4,462评论 0 5
  • 一,正则表达式分三部分 分隔符;表达式:修饰符: 二,普通字符 普通字符包括没有显式指定为元字符的所有可打印和不可...
    君满楼001阅读 471评论 0 0
  • 工作中不可避免的会用到正则表达式,现就正则做以下总结。 正则简介正则表达式是一种表达文本模式(即字符串结构)的方法...
    tiancai啊呆阅读 516评论 0 0
  • 正则一直想学学,一直也什么时间去学习,买了几本书看了一下。自定义View的东西我还会继续去写,更新时间不确定- -...
    夏沐尧阅读 251评论 0 0
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,504评论 0 13