두 문자열을 비교하고 슬래시와 백 슬래시를 무시하고 싶습니다.
예를 들어, 내 예상 결과 :
Regex found: tools/dbgprint/dbgprint.c
Trimmed from $regex->key(): base/applications\cmdutils\dbgprint\dbgprint.c
Output echo: Different!!
Regex found: base/applications/cmdutils/help/help.c
Trimmed from $regex->key(): base/applications\cmdutils\help\help.c
Output echo: This same
Regex found: dll\app\mplay32\mplay32.
Trimmed from $regex->key(): dll\app\mplay32\mplay32.c
This same
그것은 내 코드입니다 (출력은 위에서 언급 한 것과 같지 않지만 이것을 이해한다고 생각합니다).
$ROSDir = 'E:/ReactOS/';
(...)
$re = "/^\\s*\\*\\sFILE:\\s*\\K(\\S*)/m";
(...)
if (!$regex->isDot())
{
$fileContent = file_get_contents($regex->key());
preg_match_all($re, $fileContent, $matches);
if (isset($matches[0][0]))
{
echo 'File: <b>'. $regex->key() .'</b><br>';
echo 'Re found: '. $matches[0][0] .'<br>';
$subject = $regex->key();
$trimmed = str_replace($ROSDir, '', $subject);
echo 'Trimmed: '. $trimmed .'<br>';
if ($matches[0][0] !== $trimmed)
{
echo 'Different!!<br>';
}
}
}
(...)
$slash = str_replace('\\', '/', $trimmed);
$backslash = str_replace('/', '\\', $trimmed);
if ($matches[0][0] !== $slash && $matches[0][0] !== $backslash)
{
echo 'File: <b>'. $regex->key() .'</b><br>';
echo 'Re found: '. $matches[0][0] .'<br>';
echo 'Trimmed: '. $trimmed .'<br>';
echo 'Different!!<br>';
$diffHeader++;
echo '<hr>';
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다