Your problem is in the very first line of that regex. The dollar in ^\[$ does not match a newline. It matches right before the newline. So, that newline goes into your $1 captured by (.*) with the /s modifier. In your second substitution (the one in the eval'd part of the first one), that caret (^) will match the begining of the first line in $1 which, in your case, contains a single newline.
You can fix it by telling your regex to match an opening brace and then match as much whitespace as possible. Try changing ^\[$ to ^\[\s*.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: automagic-HTML regex
by sauoq
in thread automagic-HTML regex
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |