I can not make a regular expression. Help!

There is such a text

Supplier Aker Solutions Malaysia, PKFZ Malaysia QS Plan ID/Project ITP Number 

Written in this order with the transitions in rows.

You need to pull Supplier any text QS Plan ID/Project (\n) ITP Number Pull everything out but the text after Suppler can be any one before QS. Already broke his head.

  • Replace text with the picture. - Qwertiy

1 answer 1

http://ideone.com/PPoTcG

 using System; using System.Text.RegularExpressions; public class Test { public static void Main() { var text = @"Supplier Aker Solutions Malaysia, PKFZ Malaysia QS Plan ID/Project ITP Number"; var match = Regex.Match(text, "Supplier\n(?:.*\n){2}(.*)\n(.*)"); var res1 = match.Groups[1]; var res2 = match.Groups[2]; Console.WriteLine(res1); Console.WriteLine(res2); } } 

http://ideone.com/4fAvXP

 using System; using System.Text.RegularExpressions; public class Test { public static void Main() { var text = @"Supplier Aker Solutions Malaysia, PKFZ Malaysia Aker Solutions Malaysia, PKFZ Malaysia QS Plan ID/Project ITP Number"; var match = Regex.Match(text, "Supplier\n(?:(?!QS).*\n)*(.*)\n(.*)"); var res1 = match.Groups[1]; var res2 = match.Groups[2]; Console.WriteLine(res1); Console.WriteLine(res2); } } 
  • Does not work. And the text "Aker Solutions Malaysia, PKFZ Malaysia" can be any. - JMNext
  • @ArturOlegovplyuh, updated for any number of lines. - Qwertiy
  • @ArthurOlegovplyuh, if it doesn’t work, make a fork on ideone and insert an example on which it doesn’t work. - Qwertiy
  • vfl.ru/fotos/e35a6b3716344897.html Empty does not find. zalivalka.ru/359138 Here is a text file in such a file you need to find it. - JMNext
  • I check regexstorm.net/tester regulars - JMNext