Provides a string validator. More...
Import Statement: | import QtQuick |
Since: | Qt 5.14 |
Instantiates: | QRegularExpressionValidator |
The RegularExpressionValidator type provides a validator, that counts as valid any string which matches a specified regular expression.
regularExpression : regularExpression
This property holds the regular expression used for validation.
Note that this property should be a regular expression in JS syntax, e.g /a/ for the regular expression matching "a".
By default, this property contains a regular expression with the pattern .*
that matches any string.
Below you can find an example of a TextInput object with a RegularExpressionValidator specified:
TextInput { id: hexNumber validator: RegularExpressionValidator { regularExpression: /[0-9A-F]+/ } }
Some more examples of regular expressions:
/\d{1,3}(?:,\d{1,3})+$/
/(\d{1,3})([.,]\d{1,2})?$/
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qml-qtquick-regularexpressionvalidator.html