|
Hi Mark,
Switchee is fantastic, thanks for making it available. I ran into an issue earlier with a regular expression that included a pipe - Switchee insisted on exploding the regex in two as it thought I was passing in a normal either/or value. I’ve put together a fix for this that makes Switchee ‘regular expression aware’. I’ve not tested it too much yet but it’s working nicely for me.
Old code:
if (stristr($val['value'], '|')) { $val_array = explode('|', $val['value']); }
New code:
if (stristr($val['value'], '|')) { // Obfuscate pipes within regexs to stop them exploding $val['value'] = preg_replace_callback('/#[^#]+(\|)[^#]+#/', create_function( '$matches', 'return str_replace("|", "REPIPE", $matches[0]);' ), $val['value']);
$val_array = explode('|', $val['value']); // Restore regex pipes $val_array = str_replace('REPIPE', '|', $val_array); }
Having built that I’ve now realised that Switchee doesn’t (I don’t think?) support mixed regex and string values anyway, so this code could be simplified. At least this option will work if you added that in the future.
Cheers,
Dom
|