Having trouble with commas in regex conditions. May just be my naivety with regex, but this works...
regexp[/^[0-9a-zA-Z\s-_.'()\/:#&]+$/]
...and this doesn't...
regexp[/^[0-9a-zA-Z\s-_.,'()\/:#&]+$/]
Note the only difference is the comma. I've tried escaping that character as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | commas_in_regex-1425268-3.patch | 556 bytes | doublejosh |
Comments
Comment #1
doublejosh commentedI've also tried using \pL to get the comma character included. Still no luck.
Doesn't work:
regexp[/^[0-9a-zA-Z-_.'()\/:#&\pL\"\\\ \\,]*$/](note double backslash because rule is in quotes.)
Comment #2
doublejosh commentedAfter using this tool to test my rule against some text, I'm convinced there's a problem with this module. Seems that when there's a comma in the regex rule it ends the rule string and breaks it. The rule gets broken apart in $params. Discovered via...
Looks like that happens here:
...which I believe is for use with length.
Comment #3
doublejosh commentedOk, here's the patch.
Comment #4
doublejosh commentedComment #5
doublejosh commentedComment #6
doublejosh commentedComment #7
doublejosh commentedThis seems like a big deal.
Made the module not usable without the patch for fairly normal text restriction to include commas.
Comment #8
pedrofaria commentedFix committed.
Thanks and sorry about the ruge delay.
Comment #9
pedrofaria commentedComment #10
doublejosh commentedAwesome. Thanks. Excited to see it get in.
Switching a site to D7 soon, in case I end up needing to make the patch for that too.
Comment #11
pedrofaria commentedThis is already ported to D7 :)
just enjoy!
thanks!
Comment #12
pedrofaria commentedComment #13
doublejosh commentedComment #13.0
doublejosh commentedbold