在一起时,preg_replace/去掉两个大写字母


preg_replace / strip only two uppercase letters when together

我这里有一个独特的东西,在一个句子中我有两个大写字母在一起。喜欢这个:

AA 电池。CA 电源。西弗吉尼亚州编年史。

等。

你如何去除那些大写字母?谢谢!!

你去吧

preg_match_all("/'b([A-Z]{2})'b/",$string,$matches);
/*
--matches
[0] => The AA batteries. The CA power. The WV chronicles.
[1] => AA
[2] => CA
[3] => WV
*/

https://regex101.com/r/rT3jK7/1

编辑 - 编辑为使用 preg_match_all 而不是preg_match