Welcome Guest, Not a member yet? Register   Sign In
Form_validation regex_match
#5

[eluser]Unknown[/eluser]
The function currently built into the form_validator library will only work for regular expressions NOT containing square brackets aka character classes.

There's a problem in Line #116 where it tries to match the array brackets in the supplied validation/prepping function.

Code:
// Is the field name an array?  We test for the existence of a bracket "[" in
// the field name to determine this.  If it is an array, we break it apart
// into its components so that we can fetch the corresponding POST data later
if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches))

You might notice it matches the parameter given in square brackets, but only until the first closing square bracket. (Non-greedy matching by ? at the end of .*) If you use character classes in your expression, the first closing bracket of the first character class is terminating the match and therefore no ending delimiter will be found for your regex rendering it useless.

Other than that this function would be a great addition to the validation rules.


Messages In This Thread
Form_validation regex_match - by El Forum - 04-05-2011, 01:16 AM
Form_validation regex_match - by El Forum - 04-05-2011, 08:05 AM
Form_validation regex_match - by El Forum - 04-05-2011, 08:13 AM
Form_validation regex_match - by El Forum - 04-05-2011, 08:54 AM
Form_validation regex_match - by El Forum - 04-18-2011, 07:28 PM
Form_validation regex_match - by El Forum - 04-19-2011, 12:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB