RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Lua]Regular Expression Help !

0 Members and 1 Guest are viewing this topic.

*
Resident Cloud
Rep:
Level 91
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:
Code: [Select]
ahref ahref :+#thc %#crankeye

Lua doesn't actually call its pattern matching regular expressions but its practically the same eg.:
Code: [Select]
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:
Code: [Select]
ahref ahref :~#thc %#crankeye
is just a simple
user = ahref
modes = ~(im only interested in modes on "#thc")

anyone got any ideas :D?

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")
« Last Edit: April 16, 2009, 05:13:38 PM by ahref »

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
I don't think anyone else uses lua

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

*
Resident Cloud
Rep:
Level 91
:( You make me sad. its a nice language :D