Starting with an explanation ... skip to the end for a quick response
To correspond to a specific fragment of the text and confirm it there, but not to include it in the correspondence, you can use positive viewing using the notation (?=regex)
This confirms that "regex" exists in this position, but only matches the original position, and not its contents.
So this gives us an expression:
.*?(?=All text before this line will be included)
Where . - any character, and *? - lazy matching (consumes the smallest possible amount, compared to the usual * , which consumes the largest possible amount).
However, in almost all regex expressions . a newline will be excluded, so we need to explicitly use the flag to include newlines. The s flag used (which stands for "Single Line Mode", although in some cases it is also called "DOTALL").
And it can be implemented in various ways, including ...
Globally for / -defined regular expressions:
/regex/s
Inline, global for regex:
(?s)regex
Inline, applies only to brackets:
(?s:reg)ex
And as an argument to the function (it depends on what language you work with the regular expression).
So, perhaps you need the following regular expression:
(?s).*?(?=All text before this line will be included)
However, there are some caveats:
Firstly, not all regular expression flavors support lazy quantifiers - you may need to simply .* (Or potentially use more complex logic depending on exact requirements if "All text up to ..." may appear several times).
Secondly, not all regular expression flavors support lookaheads, so you will need to use captured groups to get the text that you want to match.
Finally, you cannot always specify flags such as s above, so either “nothing” or a “new line” (.|\n) or maybe [\s\S] (spaces, not spaces ) to get the equivalent of matching.
If you are limited to all of these (I think the XML implementation), then you have to do:
([\s\S]*)All text before this line will be included
And then extract the first subgroup from the result of the match.