Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 22253

Scripting • Re: check that the username variable is valid

$
0
0
viewtopic.php?p=1020866#p1020866


Instead of lost time to identify unsupported RouterOS characters (from 0x80 to 0xFF) or invalid / not printable / with problems,
simply:

example code

:global uvalid do={    # \2D = -    # \2E = .    # \30..\39 = 0..9    # \40 = @    # \41 .. \5A = A..Z    # \5F = _    # \61..\7A a..z    # so, in this case, the accepted characters are: - . 0..9 @ A..Z _    :if ($1~"[\01-\2C\2F\3A-\3F\5B-\5E\60\7B-\FF]") do={ return false }    :return true}{:local uname "inval!d=user":put "$uname is valid is $[$uvalid $uname]":local uname "Av@l1d_user.":put "$uname is valid is $[$uvalid $uname]"}

Statistics: Posted by rextended — Thu May 30, 2024 1:47 pm



Viewing all articles
Browse latest Browse all 22253

Trending Articles