我想得到两个字符串。行中的最后一个词(在下面有效),然后是最后一个词,我想用正则表达式来做到这一点。有人建议我使用^(.*?)\b\w+$作为模式并使用$1作为匹配项(但我不知道如何在 .NET 中完成)
Dim s As String = " Now is the time for all good men to come to the aid of their country "
s = Regex.Replace(s, "^[ \s]+|[ \s]+$", "") 'Trim whitespace
Dim lastword As String = Regex.Match(s, "\w*$", RegexOptions.None).ToString
Debug.Print(lastword)
Dim therest As String = Regex.Match(s,......)