Skip to content

Instantly share code, notes, and snippets.

@DanielOaks
Last active June 25, 2022 07:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DanielOaks/ef8b21a25a4db5899015 to your computer and use it in GitHub Desktop.
Save DanielOaks/ef8b21a25a4db5899015 to your computer and use it in GitHub Desktop.
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