2011-06-20 68 views
0

PHP的preg_match我需要使用的preg_match來檢查線與結尾/>或/>
我創建了一個功能,即包含followling線結束標籤

if (!preg_match('\/>$', $str)) { 

但不工作,因爲它帶有這個錯誤

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash 

我怎樣才能使它工作?

+0

可能重複(http://stackoverflow.com/questions/3464180/php-help-with-regular-expressions- error-delimiter-must-not-be-alphanumeric) – netcoder

回答

2

添加\之間的可選空間>。

if (!preg_match('|\/ ?>$|', $str)) { 
[正則表達式... PHP幫助錯誤:分隔符不能是字母數字]的
+0

謝謝:D 我已經看到,PHP需要|或類似的東西 – The87Boy

+0

-0.00001沒有完全回答問題 - 提問者的問題是缺乏答案沒有明確提及的模式的分隔符。我會授予答案對可選空間的幫助。 – jah

相關問題