Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果要匹配字符串中的以下内容:[test:ANY STRING]。
例如:[test:abc] [test:thisIsAnotherString] [test:y]
什么样的正则表达式会匹配这个?
给你试试这个
$s = 'abc[test:abcd]cb'; $matches = array(); $t = preg_match('#\[test:(.*?)\]#s', $s, $matches); if($matches[1]) echo "match"; else echo "not";