I have a regex that should check if a string consists of strings separated by spaces. The regex works well (well, it allows blank space at the end ... but that is not a problem), but takes too long when the validation fails.
The regular expression is as follows:
/^(([\w\-]+)( )?){0,}$/
When trying to check with string
"'this-is_SAMPLE-scope-123,this-is_SAMPLE-scope-456'"
It takes 2 seconds.
The tests were carried out in ruby 1.9.2-rc1 and 1.8.7. But this is probably a common problem.
Any idea?
source
share