vendredi 2 octobre 2015

Evaluation of a valid FQDN on bash regex

I am trying to make this regex work to evaluate if the string is or not a valid FQDN with no success. I went through various searches with no success too.

For example, I copied a regex find at http://ift.tt/1O8IsuN and tried this way but is not working. What can be wrong?

#!/bin/bash

fqdn=$1
if [[ "$fqdn" =~ (?=^.{1,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$) ]]
then
        echo "$fqdn is a FQDN"
else
        echo "$fqdn is NOT a FQDN"
fi
exit

Aucun commentaire:

Enregistrer un commentaire