Raised This Month: $12 Target: $400
 3% 

[TUT] Regular Expressions


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-17-2012 , 21:20   Re: [TUT] Regular Expressions
Reply With Quote #11

Quote:
Originally Posted by Backstabnoob View Post
Also, can you split a string using a regex pattern in pawn?
What do you mean by that?
__________________
fysiks is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-18-2012 , 05:26   Re: [TUT] Regular Expressions
Reply With Quote #12

Like strtok, but instead of delimiter use a regex pattern. PHP preg_split() would be a good example.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-18-2012 , 10:22   Re: [TUT] Regular Expressions
Reply With Quote #13

Try this include.

Spoiler


Code:
#include <amxmodx> #include <regex_split> public plugin_init() {         new ret, error[128];     new Regex:pattern = regex_compile_split(" ", ret, error, charsmax(error));         new output[10][2];     new count = regex_split_c("1 2 3 4 5 6 7 8 9", pattern, ret, output, sizeof(output), charsmax(output[]));         for(new i = 0; i < count; i++) {                 log_amx("Found: %s", output[i]);             }         count = regex_split("a:b:c d:e", " ", ret, output, sizeof(output), charsmax(output[]), error, charsmax(error));         for(new i = 0; i < count; i++) {                 log_amx("Found: %s", output[i]);             } }
Attached Files
File Type: inc regex_split.inc (4.3 KB, 253 views)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-18-2012 at 10:23.
Exolent[jNr] is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-19-2012 , 04:36   Re: [TUT] Regular Expressions
Reply With Quote #14

Very cool, definitely going to try it.

In my opinion it should be implemented in the regex library together with amxmodx as it usually is a really important feature of regular expressions.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-19-2012 , 09:01   Re: [TUT] Regular Expressions
Reply With Quote #15

I also wrote up a regex_replace() function. I might try extending the RegEx module as my first module submission.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-19-2012 , 11:01   Re: [TUT] Regular Expressions
Reply With Quote #16

Absolutely awesome job, I was looking for a replace function the other day as well.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-21-2012 , 17:49   Re: [TUT] Regular Expressions
Reply With Quote #17

Thanks a lots !!!!!
__________________
Pawn ? Useless
Aooka is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-24-2012 , 06:53   Re: [TUT] Regular Expressions
Reply With Quote #18

Pretty nifty, I suppose I could incorporate this into something chat-wise.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 04-28-2018 , 13:48   Re: [TUT] Regular Expressions
Reply With Quote #19

Solved!
Delete THIS!
__________________

Last edited by CrAzY MaN; 04-28-2018 at 14:07.
CrAzY MaN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode