正则表达式学习

文章目录

定义

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

基础表达式

注意:不同的环境语系会导致不同选取结果,这里以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


Now let’s start to do something with this file. For example, i want to know

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值