문자열의 시작 부분에 'http : //'및 '/'와 끝이 포함되도록 정규식을 만들고 싶습니다. 나는이 두 표현은 아래와 같이 함께 넣을 수 있습니다 생각preg_match : 시작과 끝이 무언가를 포함하고 있는지 확인하십시오.
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 /."/>';
}
하지만
이 내가 생각 해낸 더 긴 버전입니다,하지만 늘 일,
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."/>';
}
여러 표현이 I 결합하려고하면 잘못되었습니다! 어떤 생각?
덕분에, 라우 앞에
당신이 문자열 샘플을 제공 할 수 있습니다 :
다음과 같은 출력을 생성? – Codex73