What I want to do is find all the spaces enclosed in braces, and then replace them with another character.
Sort of:
{The quick brown} fox jumps {over the lazy} dog
To go to:
{The*quick*brown} fox jumps {over*the*lazy} dog
I’ve already searched on the Internet, but that’s just what I’ve got so far, and it seems so close to what I really want.
preg_replace('/(?<={)[^}]+(?=})/','*',$string);
My problem with the code above is that it replaces everything:
{*} fox jumps {*} dog
I studied regular tutorials to figure out how I should change the code above to just replace spaces, but to no avail. Any input would be appreciated.
Thank.
source
share