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

preg_replace / strip only two uppercase letters when together

当我在一个句子中有两个大写字母在一起时,我在这里有一个独特之处。像这样:

AA 电池。 CA 的权力。 WV 编年史。

等等

我如何去掉那些大写字母?谢谢!!

给你

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

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