function rules_data_text_comparison

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 454

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);
    }
}