SA-MP Forums Archive
[Plugin] Pawn.Regex - full support of regular expressions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] Pawn.Regex - full support of regular expressions (/showthread.php?tid=609570)

Pages: 1 2


Re: Pawn.Regex - full support of regular expressions - [DK]Dark_Knight - 18.02.2019

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


Re: Pawn.Regex - full support of regular expressions - Calisthenics - 18.02.2019

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



Re: Pawn.Regex - full support of regular expressions - dirigent00 - 17.06.2019

Anyone that can help out to make this: https://sampforum.blast.hk/showthread.php?tid=568668 just using this Plugin? I would much appreciate!


Re: Pawn.Regex - full support of regular expressions - YourShadow - 30.05.2020

1.1.3:


Re: Pawn.Regex - full support of regular expressions - muningcat05 - 05.06.2020

Quote:
Originally Posted by YourShadow
View Post
1.1.3:
  • Fixed replacement null length
  • Fixed multibyte strings
  • Completely rewritten using samp-ptl
I think the include file is not included on the new version 1.1.3.


Re: Pawn.Regex - full support of regular expressions - YourShadow - 05.06.2020

Quote:
Originally Posted by muningcat05
View Post
I think the include file is not included on the new version 1.1.3.
https://github.com/urShadow/Pawn.Reg...Pawn.Regex.inc


Re: Pawn.Regex - full support of regular expressions - muningcat05 - 05.06.2020

Quote:
Originally Posted by YourShadow
View Post
I got it now. Thanks and it work