I need to validate an input from text area. It is complex and i'm unable to figure out how i can do it best? Can you guys help?
Input from the text area are basically host names or ips. The input can be of any of the following formats:
x.x.x.x (single IP)
x.x.x.x-x.x.x.x (range of IPs)
x.x.x.x/x.x.x.x (IP and mask)
x.x.x.x/xx (IP and CIDR)
URL (with or without http:// and https:// prefixes)
domain name in format: xxxxxxx.xxx
Also multiple values can be given, like: 192.168.1.1 192.168.1.2/192.168.1.4
I am able to get the lines of textbox using the following code:
$text = trim($targets);
$textAr = explode("\n", $text);
$textAr = array_filter($textAr, 'trim');
foreach ($textAr as $line) {
}
I am unable to proceed further. Please help.
Thanks, Dave