Reputation: 59
I have a unique thing here when in a sentence I have two uppercase letters together. Like this:
The AA batteries. The CA power. The WV chronicles.
etc.
How do you I strip just those uppercase letters? Thanks!!
Upvotes: 1
Views: 29
Reputation: 597
Here ya go
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 - Edited to use preg_match_all instead of preg_match
Upvotes: 2