Re:My favorite regex of all time
by jimwise on Monday November 12, 2012 @03:31PM
(#4774615)
This will not only miss non-ascii printing characters, but it's not even much shorter than typing
to use the explicit character class.
[ Parent
| on HN ]
The [[:print:]] will match any printable characters like åä, while the [ -~] will not.
I used this once as another safeguard against pushing binary data into the database. It was a poor system to begin with where you even have that possibility... and it happened at least once before the fix and my safeguard was in place.
"å" is perfectly valid text input in my locale.
Re:My favorite regex of all time
by EvilTerran on Tuesday November 13, 2012 @06:23AM
(#4777418)
There will be situations where you need to check specifically for 7-bit ASCII printable characters only. I've worked with APIs that require everything outside that range to be escaped/encoded into it.
Email could be an example, I guess, although I haven't worked with it enough to know whether the whole "7-bits only" thing is still an issue these days.
Re:My favorite regex of all time
by nowarninglabel on Tuesday November 13, 2012 @01:44AM
(#4776780)
I think that was his point, that he had a good use for :print: over just -~