I have a string in the format:
\"The quick __grey__ fox jumps over the lazy __brown__ dog.\"
And I want to find and replace any words (or somet
To find some substring between two closest identical delimiters, use lazy dot matching:
$pattern = '/__(.*?)__/';
See demo
To also match newlines, use /s modifier:
/s
$pattern = '/__(.*?)__/s';