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

Quote:
Originally Posted by Kar
View Post
Is this correct usage of this plugin's functions?

pawn Code:
#if defined _pawnregex_included
regex_IsValidIP(const string[])
{
    // = \\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+([(/|,.)?\\s]{1,})+(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+([(/|,.)?\\s]{1,})+(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+([(/|,.)?\\s]{1,})+(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b //  Pooh7's second
    // = ([0-9\\s]{1,})+([(\/|_,.)?\\s]{1,})+([0-9\\s]{1,})+([(\/|_,.)?\\s]{1,})+([0-9\\s]{1,})+([(\/|_,.)?\\s]{1,})+([0-9\\s]{1,}) Pooh7's
    // = (.*?)([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})(.*?)
    // = ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)([\s\.\$]+)){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\s*:\s*[0-9]+)?

    new
        result,
        regex:ipRegex = Regex_New("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)([\s\.\$\,\_\-\@\!\#\+\=\<\>]+)){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\s*:\s*[0-9]+)??");
    result = Regex_Check(string, ipRegex);
    Regex_Delete(ipRegex);
    return result;
}
#endif
No, you'd need to escape once more the escapes.

The first escape should be for regex, if you leave it that way, you're escaping the chars in Pawn and it will send the regex without the escapes \
The second escape will escape from making the escapes disappear \\ and it will send the regex query with the escape \ and will work fine.

In other words, the first for pawn, the second for regex.
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: 1 Guest(s)