“d"在正则表达式中是一个数字吗? [英] Does "d" in regex mean a digit?

查看:21
本文介绍了“d"在正则表达式中是一个数字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在 123 中,d 匹配 13 但不匹配 2.我想知道 d 是否匹配满足什么样的要求的数字?我说的是 Python 风格的正则表达式.

I found that in 123, d matches 1 and 3 but not 2. I was wondering if d matches a digit satisfying what kind of requirement? I am talking about Python style regex.

Gedit 中的正则表达式插件使用 Python 风格的正则表达式.我创建了一个文本文件,其内容为

Regular expression plugin in Gedit is using Python style regex. I created a text file with its content being

123

只有13被正则表达式d匹配;2 不是.

Only 1 and 3 are matched by the regex d; 2 is not.

一般对于中间没有其他字符的数字序列,只有奇数位匹配,偶数位不匹配.例如在 12345 中,匹配的是 135.

Generally for a sequence of digit numbers without other characters in between, only the odd order digits are matches, and the even order digits are not. For example in 12345, the matches are 1, 3 and 5.

推荐答案

[0-9] 并不总是等价于 d.在python3中,[0-9]只匹配0123456789个字符,而d匹配[0-9]和其他数字字符,例如东方阿拉伯数字٠١٢٣٤٥٦٧٨٩.

[0-9] is not always equivalent to d. In python3, [0-9] matches only 0123456789 characters, while d matches [0-9] and other digit characters, for example Eastern Arabic numerals ٠١٢٣٤٥٦٧٨٩.

这篇关于“d"在正则表达式中是一个数字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆