orunwanted_line1=blabla unwanted_line2=blabla my_variable=important_content_section1 important_content_section2 important_content_section3 unwanted_line3=blabla
I tryed the following regex:unwanted_line1=blabla unwanted_line2=blabla my_variable=important_content_section1 important_content_section2 important_content_section3 [stepxyz#xxxx]
important_content_section1 is never empty, that's why i used my_variable=.*\n but it does get what i want only if i got this:my ($getVariable) = $data =~ /(my_variable=.*\n(.+[^=]\n?)*)/;
What i want to get in $getVarible is:unwanted_line1=blabla unwanted_line2=blabla my_variable=important_content_section1 important_content_section2 important_content_section3 unwanted_line3=
Update: Based on anonymus monk response, i got the solution for first data format. This is the solution: my ($getVariable) = $data =~ /(my_variable=.*\n(?:[^=\n]*\n)*)/; How can i update the regex to stop also at the lines that match [step?my_variable=important_content_section1 important_content_section2 important_content_section3
In reply to Multiline regex by adrya407
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |