Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
IRC Message Splitting Regex
Page explaining this regex: http://danieloaks.net/irc-regex/
Raw regex:
^(?:@([^\r\n ]*) +|())(?::([^\r\n ]+) +|())([^\r\n ]+)(?: +([^:\r\n ]+[^\r\n ]*(?: +[^:\r\n ]+[^\r\n ]*)*)|())?(?: +:([^\r\n]*)| +())?[\r\n]*$
Sample IRC messages:
foo bar baz asdf
:coolguy foo bar baz asdf
foo bar baz :asdf quux
foo bar baz :
foo bar baz ::asdf
:coolguy foo bar baz :asdf quux
:coolguy foo bar baz : asdf quux
:coolguy PRIVMSG bar :lol :)
:coolguy foo bar baz :
:coolguy foo bar baz :
@a=b;c=32;k;rt=ql7 foo
@a=b\\\\and\\nk;c=72\\s45;d=gh\\:764 foo
@c;h=;a=b :quux ab test cd
:src JOIN #chan
:src JOIN :#chan
:src AWAY
:src AWAY
:cool guy foo bar baz
:gravel.mozilla.org 432 #momo :Erroneous Nickname: Illegal characters
:gravel.mozilla.org MODE #tckk +n
:services.esper.net MODE #foo-bar +o foobar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment