제대로 작동하는 것처럼 보이지만 선행 문자를 넣으면 확인하지 않으며 끝 문자를 입력하면 확인하지 않습니다.preg_match가 올바르게 작업을 수집하지 않습니다.
나는 확실히 문자열이 형식으로되어 있는지 확인하려면 :
6 Numbers | Hyphen | 1 Number | A-Z any case | Hyphen | 5 Numbers
그래서이 123456-1a-12345
및 123456-1A-12345
처럼 작동합니다.
$string = 'this12345-1A-12345'; // This works, and it shouldn't
$string = '12345-1A-12345this'; // This also works and it shouldn't
$pattern = "([0-9]{6}[-]{1}[0-9]{1}[A-Za-z]{1}[-]{1}[0-9]{5})";
echo preg_match($pattern, $string);
내가 뭘 잘못하고 있니? 죄송합니다. 저는 preg_match
을 처음 접해 보았습니다. 문법에 대한 좋은 라이브러리를 찾을 수 없습니다.
* 또한 [Open source RegexBuddy alternatives] (http://stackoverflow.com/questions/89718/is-there) 및 [온라인 정규식 테스트] (http://stackoverflow.com/questions/32282/regex-testing)를 참조하십시오. 유용한 도구 또는 더 자세한 내용은 [RegExp.info] (http://regular-expressions.info/)를 참조하십시오. – mario