|
Posted by Pedro Graca on 10/30/06 02:17
cendrizzi top-posted and totally messed it up:
> I hoped I could use RE to check from the start if it had that so it
> wouldn't require the extra string searches.
<?php
$data = array(
'<input type="text" name="no!" id="test0"> ',
'<input type="text" name="no{!}" id="test0"> ',
'<input type="text" name="test0" id="test0"> ',
'<input type="text" name="test 0" id="test0"> ',
'<input type="text" name="test{0}" id="test0"> ',
'<input type="text" name="test {0}" id="test0"> ',
'<input type="text" name="test{0}test" id="test0"> ',
'<input type="text" name="test {0} test" id="test0">',
);
$rx = '/<(input|select|textarea)[^>]*' .
# 'name\s*\=\s*\"[_a-zA-Z0-9\s]*\"' . // your original version
'name\s*\=\s*\"[_a-zA-Z0-9\s]*{[_a-zA-Z0-9\s]*}[_a-zA-Z0-9\s]*\"' .
# ---^--- ---^---
'[^>]*>/';
### I think there's a few \ too many in there,
### I didn't look at it very attentively
foreach ($data as $val) {
echo $val, ' :: ';
if (preg_match($rx, $val)) {
echo 'M';
} else {
echo 'No m';
}
echo "atch.\n";
}
?>
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Navigation:
[Reply to this message]
|