我unablt使用下面的代碼來匹配以下字符串,我不知道什麼是對正則表達式無法匹配字符串
$regex = "/\\251/i";
if (preg_match($regex, $contents)) {
echo 'good it works';
}
去的$內容如下
Shanghai Taipei Tokyo TorontoOxford is a registered trade mark of Oxford University Pressin the UK and in certain other countriesPublished in the United Statesby Oxford University Press Inc., New YorkRevised text \251 John Guy 2000
我已經試過了字符串編碼到沒有運氣
$contents = utf8_encode ($contents);
這適用於我使用的所有在線工具,我是否錯過任何內容以瞭解爲什麼它在運行時不起作用?
你想在字符串中匹配'\ 251'嗎? –
確保您沒有'$ regex'和'$ regext'的拼寫錯誤。 – Rikesh
是的,我在這個網站做了以下工作,但不是當ranhttp://www.phpliveregex.com/ – user3117904