Title: Validate answer via regex patch
Last modified: October 20, 2017

---

# Validate answer via regex patch

 *  [Richard Foley](https://wordpress.org/support/users/richardfoley/)
 * (@richardfoley)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/regex-answer-patch/)
 * thanks for the useful plugin. When the answer is checked I’d suggest using a 
   regex instead of equals as it’s much more flexible. Having to type Paris or pARIS
   or pArIs or PARIS or paris or parIS or …, well, you get the idea… Here’s a small
   patch which should fix that for you.
 *     ```
       diff --git a/wp-content/plugins/no-bot-registration/no-bot-registration.php b/wp-content/plugins/no-bot-registration/no-bot-registration.php
       index c634b133..34a798ae 100644
       --- a/wp-content/plugins/no-bot-registration/no-bot-registration.php
       +++ b/wp-content/plugins/no-bot-registration/no-bot-registration.php
       @@ -223,6 +223,7 @@ function ajdg_nobot_filter($user_login, $user_email = '', $errors = '') {
               if($question_id < count($answers_all)) {
                       $answers = $answers_all[$question_id];
                       foreach($answers as $answer) {
       +                       if( preg_match( "/^$answer$/i", trim($_POST['ajdg_nobot_answer']) ) ) return $user_login;
                               if(trim($_POST['ajdg_nobot_answer']) == $answer) return $user_login;
                       }
               }
       @@ -540,4 +541,4 @@ function ajdg_nobot_notifications_dashboard() {
                       echo '</div>';
               }
        }
       -?>
       \ No newline at end of file
       +?>
       ```
   
    -  This topic was modified 8 years, 7 months ago by [Richard Foley](https://wordpress.org/support/users/richardfoley/).

The topic ‘Validate answer via regex patch’ is closed to new replies.

 * ![](https://ps.w.org/no-bot-registration/assets/icon-256x256.jpg?rev=3113674)
 * [No-Bot Registration](https://wordpress.org/plugins/no-bot-registration/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/no-bot-registration/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/no-bot-registration/)
 * [Active Topics](https://wordpress.org/support/plugin/no-bot-registration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/no-bot-registration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/no-bot-registration/reviews/)

## Tags

 * [regex](https://wordpress.org/support/topic-tag/regex/)
 * [validate](https://wordpress.org/support/topic-tag/validate/)

 * 0 replies
 * 1 participant
 * Last reply from: [Richard Foley](https://wordpress.org/support/users/richardfoley/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/regex-answer-patch/)
 * Status: not resolved