REGEX of IRC raw messages
Posted: Tue May 20, 2008 1:18 am
Hey there. I tried doing a quick search of this site (as well as a 2 day search of google along with self testing methods myself) figuring out how to regex an irc message.
Before I ask you lovely community what regex I might be able to use, I would like to know one thing.
Is there a way to return everything between the certain symbols?
:Nick!Host@name.here PRIVMSG #channel :Good morning world
I would LIKE to easily break that above string into the pieces:
Using this code (Sorry it's compressed, I typed it for my IRC bot)
So, if it's possible to return the above list with a regex, what could I use? I'd like it to match:
:Nick!Host@name.here JOIN :#channel
:NickServ!Host@name.here NOTICE Nick :Password accepted - you are now recognized.
:Nick!Host@name.here MODE #channel +-modes To Apply
:Nick!Host@name.here TOPIC #nick :Message for new Topic
I appreciate your time. This is taken up much of my little time I have.
If you have any question, concerns, or sanity concerns in general, just ask 
Thank you.
Edit: Oh snap, got ahead of myself. Added a few more things xD
Before I ask you lovely community what regex I might be able to use, I would like to know one thing.
Is there a way to return everything between the certain symbols?
:Nick!Host@name.here PRIVMSG #channel :Good morning world
I would LIKE to easily break that above string into the pieces:
- Nick
- Host@name.here
- PRIVMSG
- #channel
- Good
- Morning
- world
Code: Select all
:[\d\w\s_-^`]+![\d\w\s_-]+@[\d\w\s_\.-]+ [\d\w\s#]+[:\d\w]+? [:+-]Code: Select all
reg_match( "/:[\d\w\s_\-\^`]+![\d\w\s_\-\^`]+@[\d\w\s_\.-]+ [\d\w\s#]+[:\d\w]+? [:+-]/", implode(' ',$ex), $aTemp);
print_r($aTemp);
:Nick!Host@name.here JOIN :#channel
:NickServ!Host@name.here NOTICE Nick :Password accepted - you are now recognized.
:Nick!Host@name.here MODE #channel +-modes To Apply
:Nick!Host@name.here TOPIC #nick :Message for new Topic
I appreciate your time. This is taken up much of my little time I have.
Thank you.
Edit: Oh snap, got ahead of myself. Added a few more things xD