John,
Hopefully this will help you out.
Sample Data:
Windows 98- Windows 2000 SP4- Windows CE- Windows Millennium Edition-
Windows Mobile for Pocket PC- Windows Mobile for Smartphone- Windows
Server 2003- Windows XP Media Center Edition- Windows XP Professional x64
Edition- Windows XP SP2- Windows XP Starter Edition
Expression:
-(?<Remainder>[^-]+)$
Returns:
Windows XP Starter Edition
Should always give you the last section in a group called Remainder
eg:
Regex rex = new RegularExpression(@"-(?<Remainder>[^-]+)$");
Match mtc = rex.Match("Windows 98- Windows 2000 SP4- Windows CE- Windows
Millennium Edition- Windows Mobile for Pocket PC- Windows Mobile for
Smartphone- Windows Server 2003- Windows XP Media Center Edition- Windows
XP Professional x64 Edition- Windows XP SP2- Windows XP Starter Edition");
if (mtc.Success)
{
Trace.Write(mtc.Groups["Remainder"].Value);
}
Enjoy.
On Wed, 29 Mar 2006 09:08:10 +0800, John A Grandy
<johnagrandy-at-yahoo-dot-com> wrote:
How to write a Regex that extracts whatever follows the final hyphen in a
string ?