The parser api (which I am not allowed to modify) gives me a string of this form:
var1 var2 \
var2continued var2continued \\\
var2continued
var3
var3continued \
var3continued
I want to split this string using regex such that:
$1 = "var1";
$2 = "var2
var2continued var2continued \\
var2continued"
$3 = "var3
var3continued \
var3continued"
Basically first variable is first non-space word after 1 or more spaces and end when space is encountered.
Second variable starts from first non-space character after first variable until line end. If last character is "\", add the next line to the second variable (don't trim white space between last character on cur line and "\"). "\" should not capture next line but returns both "\" (no escape). Only trim white space for last line.
Third variable is everything after second variable.
So far I've been able to come up with this regex which only works with one line for var2 and var3
$my_re = qr/\s+(\S+)\s+(\S+)\s+[\n](.*)/
$text =~ /$my_re/