tags:

views:

22

answers:

1

Let's say I have some text that has the pattern as shown by the four lines of text below:

foo.bar.gar
foo.bar.gar.har.mar.tar.dar.zar.daddy.whatever.mummy.whateverelse
foo.hoo.scoobydoobydoo.yay
sunday.monday

The only two things known about the pattern are that:

  1. There will be at least 1 pair of words separated by a dot (period); and
  2. The text will always end in a character that is not a dot (period).

What I Want

I want to get just the last two fragments of text and the period between them. For e.g. if the text were:

foo.bar.gar

I want to get the fragment:

bar.gar

I'd been trying for the last couple of hours but then I gave up. Help will be appreciated.

+2  A: 
resultString = Regex.Match(subjectString, @"\w*.\w*$", RegexOptions.Multiline).Groups[1].Value;
redoced
Many thanks for the correct answer.
Water Cooler v2
glad I could help
redoced