$re = '/`[^`]+`|(?:(?:[ ]{4}|[ ]{0,3}\t).+(?:[\r\n]?(?!\n\S)(?:[ ]+\n)*)+)+/';
$str = 'So, code below throws undefined if index is not existing in the array
Note: it\'s array of arrays
arr[index] = arr[index].concat(data);
Eventually I\'ve fixed it with check
`if (!array[index]) {
array[index]=[];
}`
which solved the problem.
Question: is there any javascript trick which could solve this problem easier (less lines of code, without checks, whatever)?
Here is some more code,
and a little more
One line in between
Two lines.
Three lines.
We like to preserve code exactly how it is.';
$subst = "_xCodexBlockxPlacexHolderx_";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php