You are here

function rules_data_text_comparison in Rules 7.2

Condition: Textual comparison.

Related topics

1 string reference to 'rules_data_text_comparison'
rules_data_condition_info in modules/data.rules.inc
Implements hook_rules_condition_info() on behalf of the pseudo data module.

File

modules/data.eval.inc, line 446
Contains rules integration for the data module needed during evaluation.

Code

function rules_data_text_comparison($text, $text2, $op = 'contains') {
  switch ($op) {
    case 'contains':
      return strpos($text, $text2) !== FALSE;
    case 'starts':
      return strpos($text, $text2) === 0;
    case 'ends':
      return strrpos($text, $text2) === strlen($text) - strlen($text2);
    case 'regex':
      return (bool) preg_match('/' . str_replace('/', '\\/', $text2) . '/', $text);
  }
}