Support #10025
Question about validator pregMatch
| Status: | Closed | Start date: | 2010-10-01 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Reinhard Führicht | % Done: | 0% |
|
| Category: | Error checks | |||
| Target version: | Stable v1.0 | |||
| Votes: | 0 |
Description
Hello,
I would like to add the pregMatch validator like this
errorCheck.3 = pregMatch
errorCheck.3.value = /[A-Za-z0-9-]/
but it's not working.
Could someone give me a hint please.
Thanks in advance
History
Updated by Reinhard Führicht over 2 years ago
- Category set to Error checks
- Status changed from New to Needs Feedback
- Assignee set to Reinhard Führicht
- Target version set to Stable v1.0
I just tested it locally with the current trunk version.
I think your regular expression may not be correct.
It only checks if some of the valid characters are in the string, not if the string only contains of these characters.
I modified your regex:
errorCheck.2 = pregMatch errorCheck.2.value = /^[A-Za-z0-9-]$/
This way, it works fine for me.
Updated by Stephan Bauer over 2 years ago
Hello Reinhard,
thanks for your answer but it doesn't work for me.
All other validators are working like expected.
I'm using version 0.9.9
With this pregMatch config I'm always getting the error message.
Updated by Stephan Bauer over 2 years ago
It worked with this regex:
/^[a-z0-9-]*$/i
Updated by Reinhard Führicht over 2 years ago
Interesting.
But will the modifier "i" not allow stuff like _!"§$ too?
Updated by Stephan Bauer over 2 years ago
/^[a-z0-9-]*$/i works like /^[a-zA-Z0-9-]*$/
Updated by Reinhard Führicht over 2 years ago
- Status changed from Needs Feedback to Closed
OK, I see. Regular expressions FTW :-)
Issue closed.