Raised This Month: $ Target: $400
 0% 

Why not works? ((((


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
iNvectus
Member
Join Date: Sep 2014
Location: Bulgaria
Old 10-24-2019 , 01:36   Re: Why not works? ((((
Reply With Quote #3

Your regex is kinda incorrect. You have a trailing : at the end and you do nothing with it. You validate it only until 90.40.33.22: and that's it. Another thing is that you call it on plugin initialization. I'd rather do that on client_putinserver, but you know best, you are the scripter after all.

Now you have two possibilities regarding the regular expression:
Add a trailing \d+ after the : or take a look at the regex below.
PHP Code:
^(?=\d+\.\d+\.\d+\.\d+\:[0-9]{1,5}$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}\:[0-9]{1,5}$ 
What's actually happening?
We have a positive lookahead
PHP Code:
(?=\d+\.\d+\.\d+\.\d+\:[0-9]{1,5}$) 
and a non-capturing group with 5 alternatives
PHP Code:
(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9]) 
. The rest of it you can understand it yourself with all the digit validations and the range of it. You can sum 2 by 2.

So your regex would look something like the following:
PHP Code:
new Regex:regex_handle regex_match(mUserName"^(?=\d+\.\d+\.\d+\.\d+\:[0-9]{1,5}$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}\:[0-9]{1,5}$"reterrorcharsmax(error)) 
PS:
Another thing, I would also use compiled regular expressions and use regex_match, not relying on the handle itself. Just a point of view, I guess.

Last edited by iNvectus; 10-24-2019 at 01:38.
iNvectus is offline
 



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

Forum Jump


All times are GMT -4. The time now is 02:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode