免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2016 | 回复: 13
打印 上一主题 下一主题

where can I get detail information about 正则表达式? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-09-24 09:42 |只看该作者 |倒序浏览

论坛徽章:
0
2 [报告]
发表于 2003-09-24 09:47 |只看该作者

where can I get detail information about 正则表达式?

man egrep
or
query google

论坛徽章:
0
3 [报告]
发表于 2003-09-24 09:54 |只看该作者

where can I get detail information about 正则表达式?

原帖由 "deathcult" 发表:
man egrep
or
query google
   

I have searched google and baidu  , but  there are only a little,
especially lack for instances

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-01-24 06:20:00
4 [报告]
发表于 2003-09-24 10:09 |只看该作者

where can I get detail information about 正则表达式?

看看这个能否下载

Click here

论坛徽章:
0
5 [报告]
发表于 2003-09-24 12:54 |只看该作者

where can I get detail information about 正则表达式?

[quote]原帖由 "Minsic"][/quote 发表:
     

thank you from the bottom of my heart !!

but I still can not understand the following code that you given before:    $echo $var|sed s'/\(.\)/\1 /'g|awk '{print NF}'
                                          ~~~~~~

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-01-24 06:20:00
6 [报告]
发表于 2003-09-24 14:33 |只看该作者

where can I get detail information about 正则表达式?



  1. echo $var|sed s'/\(.\)/\1 /'g|awk '{print NF}'
复制代码

这个来用来统计没有空格键的字符串还行...
\(\)一对括号里的.表示任意的字符,而sed命令替换部分的\1就代表了被替换部分第一对括号里的内容,这里就是那个任意的字符,这里的替换部分还包括了一个空格,整个sed语句的作用就是在字符串的每个字符后面加一个空格,但送入awk后,默认以空格为域分隔符,如果字符串原来就包含空格的话,就此被吞没,不能得到正确的结果了。

  1. echo $var|sed s'/\(.\)/\1\
  2. >/'g|awk 'END{print NR}'
复制代码

">"符号是PS2符号,就是在命令未敲完整就回车后出现的提示符,你可以自定义PS2变量,当然,这不在这个讨论范围内。
就是在每个字符后面加一个回车,用awk统计记录条数,这样就可以避免空格部分被吃掉...不过这方法比较麻烦...

我现在还在想呢..wc -m统计出来为什么都多了一个字符 >_<

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
7 [报告]
发表于 2003-09-24 15:09 |只看该作者

where can I get detail information about 正则表达式?

  1. ksh
  2. echo ${#var}
  3. or
  4. echo $var|awk '{print length()}'
复制代码

论坛徽章:
0
8 [报告]
发表于 2003-09-24 16:08 |只看该作者

where can I get detail information about 正则表达式?

原帖由 "Minsic" 发表:
">"符号是PS2符号,就是在命令未敲完整就回车后出现的提示符,你可以自定义PS2变量,当然,这不在这个讨论范围内。
就是在每个字符后面加一个回车,用awk统计记录条数,这样就可以避免空格部分被吃掉...不过这方..........
  
Oh , I see .   3Q
But why you did not use . directly?  while, use /( . / )   ?
I have tried, they get the same result

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-01-24 06:20:00
9 [报告]
发表于 2003-09-24 16:33 |只看该作者

where can I get detail information about 正则表达式?

原帖由 "demonzhang" 发表:
  
Oh , I see .   3Q
But why you did not use . directly?  while, use /( . / )   ?
I have tried, they get the same result
   
直接用.?怎么写的?我这是不行的啊

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
10 [报告]
发表于 2003-09-24 16:49 |只看该作者

where can I get detail information about 正则表达式?

原帖由 "Minsic" 发表:
   
直接用.?怎么写的?我这是不行的啊

  1. echo 1234567890|sed 's/./& /g'
  2. 1 2 3 4 5 6 7 8 9 0
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP