php程式碼1:
<?
$PathString = 'C:\AppServ\www\test';
print preg_replace('/e/','',$PathString);
?>
結果:
C:\AppSrv\www\tst
php程式碼2:
<?
$PathString = 'C:\AppServ\www\test';
print preg_replace('/\/','',$PathString);
?>
結果:
Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found
預期結果:
C:AppServwwwtest
如果想得到[預期結果],反斜線取代掉,那麼[php程式碼2]應該怎麼改呢?
print preg_replace('/\\\\/','',$PathString);原來是這樣. 再次感謝.preg_replace('/\x5c/','',$PathString)另外一個方法 \x5c