I'm trying to match the first occurence for the company name: EuroPayment Services S.R.L. I tried to make it non-greedy by adding ? but without success. What am I doing wrong?
Name: EuroPayment Services S.R.L.
Address: Str. Ion Cămpineanu, nr. 11, Bloc Union, etaj 8, camera 803
Name: General Motors S.R.L.
Address: Str. Ion Cămpineanu, nr. 11, Bloc Union, etaj 8, camera 803
Also, how can I match the second occurence of the company name? General Motors S.R.L
Regex to capture the first name:
Sample run here.
You can also capture the nth-name through this (just update the 0-based index part
{n}to your target e.g.{4}to get the 5th name:(?:Name:[\s\S]+?){0}Name:\s+(.*)[\s\S]*(?:Name:[\s\S]+?){1}Name:\s+(.*)[\s\S]*(?:Name:[\s\S]+?){2}Name:\s+(.*)[\s\S]*(?:Name:[\s\S]+?){3}Name:\s+(.*)[\s\S]*