You don't actually need the greedy paramater /g (although it's 'good practice' to enclose a regex between two /).
For example, this will work just as fine too:
alias testregex {
echo True/False: $regex(ip,$ip,(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))
echo Return: $regml(ip)
}
Basically, I just enclosed the regex between (), so all you really needed was to enclose it either in () or /'s. The reason you need them at the start and end of your regex is because of the comma in {1,3}, which the $regex identifier assumes is the start of ANOTHER parameter after comma.
Here is your code so it will work:
if ($regex(ip,$3-,(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))) {
Hope this helps