开发者

Matching the last sub-pattern in a pattern

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 t开发者_高级运维o 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.


resultString = Regex.Match(subjectString, @"\w*.\w*$", RegexOptions.Multiline).Groups[1].Value;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜