First, perhaps you should review your pattern. It seems little bit complicated.
If your requirement is just 2 lines after 2 consecutive linebreaks, the pattern might be the following.
(?<=\r?\n\r?\n)[^\r\n]+\r?\n[^\r\n]+
If you don’t want to change the pattern, can you try to use Regex instance as the following? It will make lower regex overhead to create instance in advance, in your case.
r = new System.Text.RegularExpressions.Regex("PATTERN")
for each{
v = r.Match(inputString)
}
Sorry for the complicated pattern. I was trying to use “Vat nr.” as anchor which meant matching an unknown number of line breaks. This is of course always slow if your input text is very large.
Use @Yoichi’s pattern or just cut out the first part of my pattern:
From:
To:
(?<=(\r?\n){2})(.+\r?\n.+)
It will give you several matches though, so be sure to pick the first one only.