Re: Expresiones regulares.
| From: | tests at tiscali dot es | Date: | Tue, 21 Oct 2003 04:43:24 +0000 |
| Subject: | Re: Expresiones regulares. | ||
| References: | 1 2 3 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-41741@lists.php.net to get a copy of this message | ||
El Dimarts 21 Octubre 2003 06:27, tests@tiscali.es va escriure:
Quedaría así:
^[-a-z0-9\._]{1}[-a-z0-9\._ ]*[-a-z0-9\._]{1}$
Pruébalo un poco, pero aparentemente funciona.
He usado este miniscript en línea de comandos para probarlo:
<?php
// borram.php
// Recogemos la cadena
$cadena = $_SERVER['argv'][1];
if( ereg( "^[-a-z0-9\._]{1}[-a-z0-9\._ ]*[-a-z0-9\._]{1}$", $cadena ) ) {
echo "ok\n";
} else {
echo "error\n";
}
?>
Y esto es lo que he probado:
[toni@t Desktop]$ php borram.php "adsf-"
ok
[toni@t Desktop]$ php borram.php "a-ds-f-"
ok
[toni@t Desktop]$ php borram.php "a-ds-f- "
error
[toni@t Desktop]$ php borram.php "-a-ds-f-"
ok
[toni@t Desktop]$ php borram.php " -a-ds-f-"
error
[toni@t Desktop]$ php borram.php "@-a-ds-f-"
error
[toni@t Desktop]$ php borram.php "-a@-ds-f-"
error
[toni@t Desktop]$ php borram.php "-a-ds-f-@"
error
Saludos
--
bicyclerepairman
tests@tiscali.es
Big black bugs bleed blue black blood but baby black bugs bleed blue blood.