求解一行代码的意思
时间:2011-05-15
来源:互联网
我的读一个程序的时候,看到一行代码是这样的
if (/^ +([0-9.-]+) +([0-9.-]+) +([0-9.-]+)/)
请问([0-9.-]中的第二个减号-代表什么意思?
if (/^ +([0-9.-]+) +([0-9.-]+) +([0-9.-]+)/)
请问([0-9.-]中的第二个减号-代表什么意思?
作者: helitrope 发布时间: 2011-05-15
回复 helitrope
[0-9.-]中的第二个-应该就是它本身
[0-9.-]中的第二个-应该就是它本身
作者: yinyuemi 发布时间: 2011-05-15
回复 yinyuemi
恩,呵呵,谢谢您啊!
恩,呵呵,谢谢您啊!
作者: helitrope 发布时间: 2011-05-15
这个在 perlre 中有讲
QUOTE:
You can specify a character class, by enclosing a list of characters in [] , which will match any character from the list. If the first character after the "[" is "^", the class matches any character not in the list. Within a list, the "-" character specifies a range, so that a-z represents all characters between "a" and "z", inclusive. If you want either "-" or "]" itself to be a member of a class, put it at the start of the list (possibly after a "^"), or escape it with a backslash. "-" is also taken literally when it is at the end of the list, just before the closing "]". (The following all specify the same class of three characters: [-az] , [az-] , and [a\-z] . All are different from [a-z] , which specifies a class containing twenty-six characters, even on EBCDIC-based character sets.) Also, if you try to use the character classes \w , \W , \s, \S , \d , or \D as endpoints of a range, the "-" is understood literally.
作者: zhlong8 发布时间: 2011-05-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28