A Regular Expression For IRC Messages reddit / irc ---------------------------------------------------------------------- mybuddymichael · 2013-03-02 17:21 Suggestions for improvement are most welcome. ---------------------------------------------------------------------- alientity · 2013-03-02 18:00 Very cool, I can appreciate the beauty of this, as I love creating IRC bots and regular expressions :) ---------------------------------------------------------------------- Gr4y · 2013-03-03 00:37 I should learn regular expressions. They seem to be very helpful when it comes to strings rather than doing it all by yourself. Great post! ---------------------------------------------------------------------- aggrolite · 2013-03-03 04:54 I put off learning regular expressions longer than I should have, simply because they looked scary. But they're fun! ---------------------------------------------------------------------- M2Ys4U · 2013-03-03 04:57 [We](https://kiwiirc.com/) use this: /^(?:(?:(?:(@[^ ]+) )?):(?:([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)|([a- z0-9\x5B-\x60\x7B-\x7D\.\-]+)!([a-z0-9~\.\-_|]+)@?([a-z0-9\.\- :\/_]+)?) )?(\S+)(?: (?!:)(.+?))?(?: :(.+))?$/i which is fairly ugly to look at, but supports [message tags](http://ircv3.org/specification/message-tags-3.2), UTF-8 and works on every IRCd we've come across. ---------------------------------------------------------------------- mybuddymichael · 2013-03-03 05:04 Nice! ---------------------------------------------------------------------- M2Ys4U · 2013-03-03 05:08 If you want to see it in action, [here](https://github.com/prawnsalad/ KiwiIRC/blob/master/server/irc/connection.js#L357) is the sourcecode.