How would I use a regular expression to match an IRC nickname? This is being done in Ruby if that makes a difference (it probably will, with the syntax of the regex, but who knows.)
EDIT: An IRC nickname can contain any letter, number, or any of the following characters: <
- [ ] \
^ { }
The above allows single-character names. If two characters are required, change the
*
to+
. If three characters (or more) are required, change it to{2,}
, where '2' is the minimum number of characters minus 1.If there is a maximum number of characters (for example, EFNet only allows nicknames up to 9 characters lone, while Freenode allows nicks up to 16 characters long) then you can include that number (minus 1) after the comma. For example: