[Plugin] Pawn.Regex - full support of regular expressions
#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


Messages In This Thread
Pawn.Regex - full support for regular expressions - by YourShadow - 14.06.2016, 07:11
Re: Pawn.Regex - full support of regular expressions - by Max_Andolini - 14.06.2016, 15:59
Re: Pawn.Regex - full support of regular expressions - by Roozevelt - 14.06.2016, 17:20
Re: Pawn.Regex - full support of regular expressions - by FuNkYTheGreat - 14.06.2016, 17:47
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 17.06.2016, 07:35
Re: Pawn.Regex - full support of regular expressions - by Gasman - 24.06.2016, 05:26
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 24.06.2016, 06:29
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 03.07.2016, 18:32
Re: Pawn.Regex - full support of regular expressions - by Luicy. - 03.07.2016, 19:22
Re: Pawn.Regex - full support of regular expressions - by Arturo226 - 03.07.2016, 20:01
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 09.07.2017, 15:45
Re: Pawn.Regex - full support of regular expressions - by Salik - 10.07.2017, 15:03
Re: Pawn.Regex - full support of regular expressions - by Barnwell - 18.07.2017, 00:22
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 24.03.2018, 13:19
Re: Pawn.Regex - full support of regular expressions - by sampkinq - 25.03.2018, 10:05
Re: Pawn.Regex - full support of regular expressions - by Kaperstone - 25.03.2018, 10:18
Re: Pawn.Regex - full support of regular expressions - by Kar - 29.03.2018, 05:40
Re: Pawn.Regex - full support of regular expressions - by Evocator - 29.03.2018, 08:01
Re: Pawn.Regex - full support of regular expressions - by Kaperstone - 30.03.2018, 14:08
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 14.04.2018, 07:39
Re: Pawn.Regex - full support of regular expressions - by [DK]Dark_Knight - 18.02.2019, 02:58
Re: Pawn.Regex - full support of regular expressions - by Calisthenics - 18.02.2019, 07:25
Re: Pawn.Regex - full support of regular expressions - by dirigent00 - 17.06.2019, 00:47
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 30.05.2020, 13:43
Re: Pawn.Regex - full support of regular expressions - by muningcat05 - 05.06.2020, 17:37
Re: Pawn.Regex - full support of regular expressions - by YourShadow - 05.06.2020, 19:07
Re: Pawn.Regex - full support of regular expressions - by muningcat05 - 05.06.2020, 19:41

Forum Jump:


Users browsing this thread: 3 Guest(s)