Page 1 of 1

preg_replace: Regular Expression question

Posted: Tue May 20, 2008 5:07 pm
by mboer
If I have the following string:

Code: Select all

$string = "John went all-in after he saw the flop (7s 8c 9d) and feels good about it.";
How would I go about setting up the regular expression so I can only replace between the ( ) brackets?

The basic pattern would be something like:

Code: Select all

preg_replace('/7s/', 'Seven of Spades', $string);
I'd appreciate any help, thx!