sed 正则表达式
来源:互联网 发布:九次方大数据员工投诉 编辑:程序博客网 时间:2024/05/29 11:39
http://learn.akae.cn/media/ch32s03.html
Welcome to the world of regexp!
Welcome to the world of regexp!
+++++++++++++++++++++++++++++
学生:卢峰
sed 's/<[a-z|/]*>//g' testfile
+++++++++++++++++++++++++++++
sed 's/<[^<>]*>//g' testfile
如果testfile的内容是
Welcome to the world of regexp!
现在要去掉所有的HTML标签,使输出结果为
Hello WorldWelcome to the world of regexp!
怎么做呢?如果用下面的命令
$ sed 's/<.*>//g' testfile结果是两个空行,把所有字符都过滤掉了。这是因为,正则表达式中的数量限定符会匹配尽可能长的字符串,这称为贪心的(Greedy)[39]。比如sed在处理第一行时,<.*>匹配的并不是或这样的标签,而是
这样一整行,因为这一行开头是<,中间是若干个任意字符,末尾是>。那么这条命令怎么改才对呢?留给读者思考。
+++++++++++++++++++++++++++++
学生:卢峰
sed 's/<[a-z|/]*>//g' testfile
+++++++++++++++++++++++++++++
sed 's/<[^<>]*>//g' testfile
0 0
- 正则表达式Sed
- sed中的正则表达式
- sed正则表达式
- sed 命令+正则表达式
- 正则表达式、sed、awk
- sed 之正则表达式
- sed 命令+正则表达式
- SED 中的正则表达式
- sed 常用正则表达式
- sed 和正则表达式
- sed 正则表达式
- sed正则表达式
- Linux正则表达式sed
- linux 正则表达式 sed
- linux sed正则表达式
- sed正则表达式
- sed 正则表达式
- 正则表达式--------SED
- 中科大Linux镜像源正式面向全国用户开张
- ServletContext 与application的异同
- Latex中设置字体颜色
- CentOS 6 初步计划有望5月发布
- 黄瓜涂上避孕药吃了会绝育-搜狐社区
- sed 正则表达式
- Systemd 进程管理器
- Dom4j解析xml文件
- VMware SDS 之二 : VSAN用在哪?
- form表单的多种提交方式
- 单工、半双工、全双工通信
- 光晶片
- ubuntu下kermit连接串口的问题
- Fedora 15 LoveLock的新特性