2017-03-24 118 views
-1

我需要的正則表達式,其將這樣的匹配字符串:匹配的字符串與某些條件(正則表達式)

如果有大寫字母「T」,則一個數(任意),則一個點,然後2在任何符號字符串的結尾。

事情是這樣的:

$stingr = "alT4.ei"; 

if (match happens with $stingr) { 
    echo "match"; 
} 
else { 
    echo "no match"; 
} 
+0

究竟是什麼問題卡住了?你有什麼嘗試?看起來正則表達式101給我。 –

回答

1

你的意思呢?

$stingr = "alT4.ei"; 

if (preg_match("#T\d\..{2}$#", $stingr)) { 
    echo "match"; 
} 
else { 
    echo "no match"; 
} 
+0

是的,作品謝謝 –