Just a Simple Quick Question.
I want to replace the Double Spaces at the begenning of the line by Tabs.
Currently I am trying with preg_replace('~^( {2})~', "\t", $text) but that replaces only the first occurrence of Double Space.
–EDIT–
preg_replace('~PATTERN~', "REPLACEMENT", " HalloWorld")
//Should be equal to "\t\t\tHallo World"
You can use \G escape sequence for that:
\G marks the location of the end of the previous match (or the beginning of the string for the first match); that way, all matches after the first one try to consume additional two spaces from the character previous match left off.