[Plugin] Pawn.Regex - full support of regular expressions
#21

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
Reply
#22

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
Reply
#23

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

1.1.3:
  • Fixed replacement null length
  • Fixed multibyte strings
  • Completely rewritten using samp-ptl
Reply
#25

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.
Reply
#26

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
Reply
#27

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


Forum Jump:


Users browsing this thread: 1 Guest(s)