Sterilizing regexp



A while ago I asked a question and got a few answers, so I thought I would
toss this out there as a follow up. I'm going to be using this to return
filtered regexp values for a user interface.

I haven't had a chance to enter this into my code yet, so if anyone sees
something wrong please hammer away, otherwise I hope it helps save some one
some time.

function regexp_sanitize($string,$regexp) {
if(isarray($string)) {
foreach($string as $key => $value) {
$count = preg_match($regexp,$value,$matches) {
if($count != 1) {
$result[$key] = FALSE;
} else {
foreach($matches as $toss => $matchval) {
$result[$key] = $matchval;
};
};
};
} else {
$count = preg_match($regexp,$string,$matches);
if($count != 1) {
$result = FALSE;
} else {
$result = $matches[0];
};
};
return($result);
};


.



Relevant Pages

  • Re: What value does the
    ... make it a 99.7% chance you will toss between 35 and 65 heads. ... Re: superstitions/old sayings. ...
    (rec.gambling.craps)
  • Re: What value does the
    ... make it a 99.7% chance you will toss between 35 and 65 heads. ... Re: superstitions/old sayings. ...
    (rec.gambling.craps)
  • Re: What value does the
    ... make it a 99.7% chance you will toss between 35 and 65 heads. ... Re: superstitions/old sayings. ...
    (rec.gambling.craps)
  • Re: rocket motor sleeves,got any?
    ... If there's a chance the tubes picked up some moisture you might want ... to toss them in the oven for a bit. ... (Without any comp in ...
    (rec.pyrotechnics)
  • Re: DONT WASTE MY (del) TIME
    ... Any chance anyone can toss me a hint on the ... Cuz posts saying "opps, this has gone ... OT, here's my e-mail" get shot down in record time, yet ...
    (microsoft.public.security.virus)