I have text like this from poker software (I have highlighted the parts I need to replace).
--- FLOP --- [Jh 9h Ah]
driverseati checks
darrington has 15 seconds left to act
darrington bets 100
InvisibleEnigma calls 100
driverseati folds
--- TURN --- [Jh 9h Ah] [3c]
darrington bets 200
InvisibleEnigma calls 200
--- RIVER --- [Jh 9h Ah 3c] [Td]Jh = Jack of hearts
9h = 9 of hearts
Ah = ace of hearts
3c = 3 of clubs
I want to replace the cards inside the square brackets with IMAGES.
So this line: --- TURN --- [Jh 9h Ah] [3c]
Needs to become: --- TURN --- jh.gif 9h.gif ah.gif 3c.gif
I can't figure out the preg_replace :( I can kind of figure it out for just a single card inside brackets (like the [3c]), but I'm stuck at replacing multiple instances on 1 line and some brackets having 3 cards and some brackets having 2, or 1 card.
This is what I have for a single card:
\[([AKQJakqj1-9]0?[DHSCdhsc])\]
Any help would be appreciated.