I'm trying to work with some regex in PHP but there is something i don't understand. Here is my text:
# fhzmvbzmvbzmb#@!
# blabla
# test
sbsfzzbg
And let's say i want to emphasise it as in markdown. Why does the following function apply to my second line only ? I would expect it to apply to the third line as well.
preg_replace("/\n(.*)\n/", "<h1>$1</h1>", $input_lines);
Also, i want to catch the first line. Is there a way to write the expression i am trying to catch could either be at the beginning of the string or not ? I've thought about the next function but it doesn't seem to work:
preg_replace("/(^|\n)(.*)\n/", "<h1>$1</h1>", $input_lines);
Thank you very much. Pierrick