\d less efficient than [0-9]
41–50 of 80 posts
Re: \d less efficient than [0-9]
#42Earlier quoted context omitted.
...at least in C# regexes.
Anyone know if this happens in other languages?
Re: \d less efficient than [0-9]
#43Regex is a really powerful tool, but sometimes I wonder just how well people actually understand it as the vast majority of people (myself included) seem to be self taught in the syntax - only learning the bits they need as and when they need it. The problem is, regular expressions is packed full of counter intuitive idiosyncrasies which make perfect sense once they're explained, but are far from obvious. Take this f…
Re: \d less efficient than [0-9]
#44Earlier quoted context omitted.
Nor in python: print re.match(r'\d','੧') None
it does when using the re.U flag re.match(r'\d', u'੧', re.U) sys.version 2.7.3 (default, Mar 4 2013, 14:57:34) \n[GCC 4.7.2]
Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match(r'\d', '੧')
Re: \d less efficient than [0-9]
#45I wonder what kind of security vulnerabilities could be looming in validators not expecting non-ascii 0-9 digits and using this regex?
Re: \d less efficient than [0-9]
#46Re: \d less efficient than [0-9]
#47Short answer: \d includes all the Unicode characters from http://www.fileformat.info/info/unicode/category/Nd/list.htm
Is that actually a good thing? If I'm using \d to validate numbers (for example to check before string to int conversion, or IP address, phone number, or any other use), other unicode digits are not helpful to me. It's great to support unicode, but I don't think the \d should have been extended this way. Add a \ud or something.
Re: \d less efficient than [0-9]
#48Regex is a really powerful tool, but sometimes I wonder just how well people actually understand it as the vast majority of people (myself included) seem to be self taught in the syntax - only learning the bits they need as and when they need it. The problem is, regular expressions is packed full of counter intuitive idiosyncrasies which make perfect sense once they're explained, but are far from obvious. Take this f…
s/^\s+?(.*)\s+?$/$1/gRe: \d less efficient than [0-9]
#49Regex is a really powerful tool, but sometimes I wonder just how well people actually understand it as the vast majority of people (myself included) seem to be self taught in the syntax - only learning the bits they need as and when they need it. The problem is, regular expressions is packed full of counter intuitive idiosyncrasies which make perfect sense once they're explained, but are far from obvious. Take this f…
Use the s/, Luke s/^\s+?(.*)\s+?$/$1/g
Re: \d less efficient than [0-9]
#50 $ echo "ä" | LC_COLLATE=C grep '[a-z]'
$ echo "ä" | LC_COLLATE=en_US.UTF-8 grep '[a-z]'
ä
For common values of LC_COLLATE, the range [a-z] does not exclude accented characters and umlauts.