SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 18/02/2019, 02:58 AM   #31
[DK]Dark_Knight
Huge Clucker
 
[DK]Dark_Knight's Avatar
 
Join Date: Apr 2008
Location: New Zealand
Posts: 212
Reputation: 21
Default Re: Pawn.Regex - full support of regular expressions

Plugin works great

However how does one replace text with nothing
Code:
new Regex:r = Regex_New("Test ");
Regex_Replace("My Test Text", r, "", str);
Without getting the error
Code:
[Pawn.Regex] Plugin::n_regex_replace: invalid str or fmt
If i put any text into the format it works sweet as, but with nothing error.
Normally I would open up the plugin source and sus it out myself, however I am out of town for a while and only have my craptop
__________________

Need help with your code or server?
I am willing to help out with your project.
Send me your discord add in a private message along with what you are looking at getting done and I will get in contact with you.
Help Thread
[DK]Dark_Knight is offline   Reply With Quote
Old 18/02/2019, 07:25 AM   #32
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 646
Reputation: 96
Default Re: Pawn.Regex - full support of regular expressions

Quote:
Originally Posted by [DK]Dark_Knight View Post
Plugin works great

However how does one replace text with nothing
Code:
new Regex:r = Regex_New("Test ");
Regex_Replace("My Test Text", r, "", str);
Without getting the error
Code:
[Pawn.Regex] Plugin::n_regex_replace: invalid str or fmt
If i put any text into the format it works sweet as, but with nothing error.
Normally I would open up the plugin source and sus it out myself, however I am out of town for a while and only have my craptop
First method: group begin-end and concatenate them.

pawn Code:
main()
{
    new Regex: r = Regex_New("^(.+?)?Test\\s(.+?)?$");
   
    if (r)
    {
        new RegexMatch: m,
            group_1[128], group_2[128],
            group_1_length, group_2_length;

        if (Regex_Match("My Test Text", r, m))
        {
            Match_GetGroup(m, 1, group_1, group_1_length);
            Match_GetGroup(m, 2, group_2, group_2_length);

            Match_Free(m);
           
            strcat(group_1, group_2);
            print(group_1);
        }
       
        Regex_Delete(r);
    }
}

Second method: find and replace special character.

pawn Code:
main()
{
    new Regex:r = Regex_New("Test ");
   
    if (r)
    {
        new str[128];
       
        Regex_Replace("My Test Text", r, "\1", str);
        Regex_Delete(r);
       
        strreplace(str, "\1", "");
        print(str);
    }
}

// `strreplace` function from Slice's strlib

Last edited by Calisthenics; 18/02/2019 at 08:21 AM.
Calisthenics is offline   Reply With Quote
Old 17/06/2019, 12:47 AM   #33
dirigent00
Big Clucker
 
Join Date: Jul 2014
Posts: 72
Reputation: 1
Default Re: Pawn.Regex - full support of regular expressions

Anyone that can help out to make this: https://forum.sa-mp.com/showthread.php?t=568668 just using this Plugin? I would much appreciate!
dirigent00 is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] Regular Expressions Plugin v0.2 (RegEx) Koala818 Plugin Development 22 09/09/2016 07:36 AM
Need help and full support monkuttan Server Support 33 16/11/2013 02:35 PM
expressions string to expressions? iJumbo Scripting Help 7 04/05/2013 02:33 PM
[REGEX] Acceptable nickname regular expression ikkentim Scripting Help 1 29/01/2013 08:13 PM


All times are GMT. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.