In both cases I'm using a zero assertion lookahead like (?=^[^\\]) to ensure the next line continues to have what I'm looking for.
(?= start the zero assertion lookahead, this requirs the value to exist but does not consume the value
^[^\\] match the a start of a line followed by any character then a \
) close the assertion
Part 1
This will match all text for part 1 where the first line captured is followed by any number of lines with \.
^([^\\].*?)(?=^[^\\])

Edit live on Debuggex
Java Code Example:
import java.util.regex.Pattern;
import java.util.regex.Matcher;
class Module1{
public static void main(String[] asd){
String sourcestring = "STARTFirstText blah, blah
\ 1next line with more text, but the leading backslash
\ 2next line with more text, but the leading backslash
\ 3next line with more text, but the leading backslash
STARTsecondText blah, blah
\ 4next line with more text, but the leading backslash
\ 5next line with more text, but the leading backslash
\ 6next line with more text, but the leading backslash
foo";
Pattern re = Pattern.compile("^([^\\\\].*?)(?=^[^\\\\])",Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
Matcher m = re.matcher(sourcestring);
int mIdx = 0;
while (m.find()){
for( int groupIdx = 0; groupIdx < m.groupCount()+1; groupIdx++ ){
System.out.println( "[" + mIdx + "][" + groupIdx + "] = " + m.group(groupIdx));
}
mIdx++;
}
}
}
$matches Array:
(
[0] => Array
(
[0] => STARTFirstText blah, blah
\ 1next line with more text, but the leading backslash
\ 2next line with more text, but the leading backslash
\ 3next line with more text, but the leading backslash
[1] => STARTsecondText blah, blah
\ 4next line with more text, but the leading backslash
\ 5next line with more text, but the leading backslash
\ 6next line with more text, but the leading backslash
)
[1] => Array
(
[0] => STARTFirstText blah, blah
\ 1next line with more text, but the leading backslash
\ 2next line with more text, but the leading backslash
\ 3next line with more text, but the leading backslash
[1] => STARTsecondText blah, blah
\ 4next line with more text, but the leading backslash
\ 5next line with more text, but the leading backslash
\ 6next line with more text, but the leading backslash
)
)
Part 2
This will match the first line followed by several lines of with which start with number
^([^\d].*?)(?=^[^\d])

Edit live on Debuggex
Example
import java.util.regex.Pattern;
import java.util.regex.Matcher;
class Module1{
public static void main(String[] asd){
String sourcestring = "First you will see the following links for the items:
1111 leading 4 digits and then some text
2565 leading 4 digits and then some text
8978 leading 4 digits and then some text
Second you will see the following links for the items:
2222 leading 4 digits and then some text
3333 leading 4 digits and then some text
4444 leading 4 digits and then some text";
Pattern re = Pattern.compile("^([^\\d].*?)(?=^[^\\d])",Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
Matcher m = re.matcher(sourcestring);
int mIdx = 0;
while (m.find()){
for( int groupIdx = 0; groupIdx < m.groupCount()+1; groupIdx++ ){
System.out.println( "[" + mIdx + "][" + groupIdx + "] = " + m.group(groupIdx));
}
mIdx++;
}
}
}
$matches Array:
(
[0] => Array
(
[0] => First you will see the following links for the items:
1111 leading 4 digits and then some text
2565 leading 4 digits and then some text
8978 leading 4 digits and then some text
[1] =>
)
[1] => Array
(
[0] => First you will see the following links for the items:
1111 leading 4 digits and then some text
2565 leading 4 digits and then some text
8978 leading 4 digits and then some text
[1] =>
)
)