Sterilizing regexp
- From: blindspotpro@xxxxxxxxxxx ("Frank Stanovcak")
- Date: Tue, 30 Sep 2008 13:45:21 -0400
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);
};
.
- Follow-Ups:
- Re: [PHP] Sterilizing regexp
- From: Jim Lucas
- RE: [PHP] Sterilizing regexp
- From: "Boyd, Todd M."
- Re: [PHP] Sterilizing regexp
- From: Per Jessen
- Re: [PHP] Sterilizing regexp
- Prev by Date: Re: [PHP] Digital signature
- Next by Date: Re: [PHP] Sepating MySQL result set into html tables
- Previous by thread: Re: [PHP] db_* => pg_*/my_*/ifx_* ?
- Next by thread: Re: [PHP] Sterilizing regexp
- Index(es):
Relevant Pages
|