Index: text.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/text.module,v
retrieving revision 1.38
diff -u -F^f -r1.38 text.module
--- text.module	13 Aug 2006 15:24:41 -0000	1.38
+++ text.module	18 Sep 2006 16:14:30 -0000
@@ -54,10 +54,17 @@ function text_field_settings($op, $field
         '#rows' => 10,
         '#description' => t('The possible values this field can contain. Any other values will result in an error. Enter one value per line.'),
       );
+      $form['allowed_values_match'] = array(
+        '#type' => 'radios',
+        '#title' => t('Allowed values matching'),
+        '#default_value' => isset($field['allowed_values_match']) ? $field['allowed_values_match'] : 0,
+        '#options' => array(0 => t('Exact'), 1 => t('Regular Expression')),
+        '#description' => t('The type of matching to perform for allowed values. Only use Regular Expressions on Text Fields.')
+      );
       return $form;
 
     case 'save':
-      return array('text_processing', 'max_length', 'allowed_values');
+      return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_match');
 
     case 'database columns':
       $columns = array(
@@ -120,8 +127,17 @@ function text_field($op, &$node, $field,
       if (is_array($node_field)) {
         foreach ($node_field as $delta => $item) {
           if ($item['value'] != '') {
-            if (count($allowed_values) && !in_array($item['value'], $allowed_values)) {
-              form_set_error($field['field_name'], t('Illegal value for %name.', array('%name' => t($field['widget']['label']))));
+            if (count($allowed_values)) {
+              if ($field['allowed_values_match']) {
+                foreach ($allowed_values as $allowed) {                  
+                  if (preg_match($allowed, $item['value'])) {
+                    return;
+                  }
+                }
+              }
+              if ($field['allowed_values_match'] || !in_array($item['value'], $allowed_values)) {
+                form_set_error($field['field_name'], t('Illegal value for %name.', array('%name' => t($field['widget']['label']))));
+              }
             }
           }
         }
