I got this error message while trying to create validation using "Regular Expression".
Please tell me where I did wrong, or someone please tell me any other way to write this Regex.

Regex code: |/^\d[A-L][A-GZ][A-Z][0A-Z]\d\d\d\d\d/|
Test String: 8LAT000001

I get this error as shown below;

Warning: preg_match() [function.preg-match]: Unknown modifier '^' in webform_validation_webform_validation_validate() (line 370

Thanks in advance.

Comments

Bright Web Design’s picture

Warning: preg_match() [function.preg-match]: Unknown modifier '^' in webform_validation_webform_validation_validate() (line 370 of C:\xampp\htdocs\drupal7\sites\all\modules\webform_validation\webform_validation.validators.inc).

I forgot to add full error, here it is.

svendecabooter’s picture

Status: Active » Needs work

Hi,

The pattern delimiters are already in the code itself.
So the regex code you enter should be just ^\d[A-L][A-GZ][A-Z][0A-Z]\d\d\d\d\d

However there could be a case where there are still characters after the pattern delimiters (e.g. /regex/i for case insensitive search), so that's posing a problem right now. But if I change that behavior, an upgrade path & clear explanation should be provided.
I'll have to think about the best approach for that...

svendecabooter’s picture

Status: Needs work » Active
svendecabooter’s picture

Status: Active » Fixed

Actually we use mb_ereg(), which doesn't need delimiters.
I have updated the validation rule help text to make clear that delimiters shouldn't be added.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.