Q:

PHP preg_replace to insert string into input string

I have a string in format: 
Rooms available: Master bedroomDining roomLiving room

I want to convert this string into like:
Rooms available: Master bedroom, Dining room, Living room

So, inserting a ', ' (comma and space) in between each lowercase_char[here]UPPERCASE_CHAR
Getting the lowercase_charUPPERCASE_CHAR is easy but can't figure out how to insert ', ' in between them. 
Anyone?

A:

If you are using a regex, you need to put the each letter in its own capture group, so you can split them apart.
$string = 'Rooms available: Master bedroomDining roomLiving room';

$string = preg_replace('/([a-z])([A-Z])/', '$1, $2', $string);

DEMO: https://regex101.com/r/vQ6hP7/1

