Validate IP address or hostname with port & range check with RegExpValidator

  • QT 5.9.2 … Android



    Works with online reg tester with /m multiline option but not with QT Qml … is there a way to validate ip and hostname

    TextField {
    id: serverIpText
    height: 24
    maximumLength: 255
    cursorVisible: true
    // DNS allows alphanumeric and hyphens... dots are in IP address... and : separates optional port number
    validator: RegExpValidator {
    regExp: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(:\d{1,5})$|^((([a-zA-Z]|[a-zA-Z0-9][a-zA-Z0-9-][a-zA-Z0-9]).)([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-][A-Za-z0-9]))(:\d{1,5})*$/

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.