Hi there. Im writing an irc bot and am having to use regular expressions everywhere to wade through the crap that is RAW IRC. I have found a few patterns online that split stuff down nicely. I however cannot find or stumble uppon a regular expression or group of regular expressions that will return the data i need from the following line:
ahref ahref :+#thc %#crankeye
Lua doesn't actually call its pattern matching regular expressions but its practically the same eg.:
prefix, cmd, param = string.match(p, "^:([^ ]+) ([^ ]+)(.*)$")
splits a line into its base parts eg. ":ahref!~ahref@FDC777BF.FFB88ACD.E46257AB.IP PRIVMSG #THC :cowbot" to
prefix = ahref!~ahref@FDC777BF.FFB88ACD.E46257AB.IP
cmd = PRIVMSG
param = #THC :cowbot
what i need from:
ahref ahref :~#thc %#crankeye
is just a simple
user = ahref
modes = ~(im only interested in modes on "#thc")
anyone got any ideas
?
EDIT: i can now get the FIRST nickname with " ([%w]+)" but i want the second.
EDIT4: got them both first one seems a bit hacky but meh
nick = string.match(param,"[%w] ([%w]+)")
modes = string.match(param, "([+%%~&@])#thc")