Desidero avere un'espressione regolare che assicuri che l'inizio della stringa contenga "http: //" e "/" e la fine.preg_match: assicurarsi che l'inizio e la fine contengano qualcosa
Questa è una versione più lunga che mi è venuta,
if(!preg_match("/(^http:\/\//", $site_http))
{
$error = true;
echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm that your link contains http:// at the start."/>';
}
elseif (!preg_match("/\/$/", $site_http))
{
$error = true;
echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm that your link has ended with a /."/>';
}
ma ho pensato che queste due espressioni possono mettere insieme come qui di seguito, ma non funzionerà,
if(!preg_match("/(^http:\/\/)&(\/$)/", $site_http))
{
$error = true;
echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm that your link contains http:// at the start and a/at the end."/>';
}
le molteplici espressioni che ho provare a combinare deve essere sbagliato! qualche idea?
grazie, Lau
Potete fornire un campione di stringa? – Codex73