irc

C#

static void Main(string[] args){
Regex r = new Regex(@"^(?::(?:([^\s!@]+)(?:(?:!([^\s!@]+))?@([^\s!@]+))?)\s)?([^\s:]+)(?:\s(.*))?$");
string s = ":nickname!-user@h.o.st PRIVMSG #キクチ系:*.jp :萠え〜";
GroupCollection gc = r.Match(s).Groups;
for(int i = 0; i < gc.Count; i++)
Console.WriteLine(string.Format("[{0}]{1}", i, gc[i]));
}
出力…
[0]:nickname!-user@h.o.st PRIVMSG #キクチ系:*.jp :萠え〜
[1]nickname
[2]-user
[3]h.o.st
[4]PRIVMSG
[5]#キクチ系:*.jp :萠え〜
…完璧♪