From my understanding you want to match any sentence ending in ?!. and ellipsis '...' while ignoring text inside „“. You also want to not end match on any single number or capital followed by ?!. or ...
In that case, this will work:
([^„]*?(„[^“]+?“)*)+?(?<!\b[\dA-Z])([?!]|[.]{1,3})
Code examples:
public static void Main()
{
string pattern = @"([^„]*?(„[^“]+?“)*)+?(?<!\b[\dA-Z])([?!]|[.]{1,3})";
string input = "Šios sutarties sąlygos taikomos „Microsoft. Hotmail“, „Microsoft. SkyDrive“, „Microsoft“ abonementui.";
var matches = Regex.Matches( input, pattern );
foreach( Match match in matches )
{
Console.WriteLine(match.Value.Trim());
}
}
Ouput:
Šios sutarties sąlygos taikomos „Microsoft. Hotmail“, „Microsoft. SkyDrive“, „Microsoft“ abonementui.
For input: 1.The „Acme. Photo“ is good. Test string „Microsoft. Hotmail“... Some more text? Even more text! Final text.
Ouput:
1.The „Acme. Photo“ is good.
Test string „Microsoft. Hotmail“...
Some more text?
Even more text!
Final text.
Explanation of regex: ([^„]*?(„[^“]+?“)*)+?(?<!\b[\dA-Z])([?!]|[.]{1,3})
[^„]*?
Match anything that is not '„'. *? means a lazy match (non-greedy).
([„][^“]+?[“])*
follow this match with 0 or more instances of „“
+?
means match this 1 or more times lazily (i.e. everything before !,?,.,...)
(?<!\b[\dA-Z])
means do a negative lookbehind for a single digit or uppercase letter. Basically, don't match ?!. or ... if preceded by number or capital.
([?!]|[.]{1,3})
means match follow the previous match with ? or ! or 1 to 3 . (dots/periods)
Normally I would use (?>) for performance, but I thought we would keep the regex simple. This site is very helpful.
Hope that helps.