RegularExpressionValidator QML Type

문자열 유효성 검사기를 제공합니다. 더 보기...

Import Statement: import QtQuick
In C++: QRegularExpressionValidator

속성

상세 설명

정규식 유효성 검사기 유형은 지정된 정규식과 일치하는 모든 문자열을 유효한 것으로 간주하는 유효성 검사기를 제공합니다.

IntValidator, DoubleValidator, 및 입력 텍스트 유효성검사도 참조하세요 .

속성 문서

regularExpression : regularExpression

이 프로퍼티에는 유효성 검사에 사용되는 정규식이 저장됩니다.

이 속성은 JS 구문의 정규식이어야 합니다(예: "a"와 일치하는 정규식의 경우 /a/).

기본적으로 이 속성에는 모든 문자열과 일치하는 .* 패턴의 정규식이 포함됩니다.

아래에서 RegularExpressionValidator 이 지정된 TextInput 객체의 예를 확인할 수 있습니다:

TextInput {
    id: hexNumber
    validator: RegularExpressionValidator { regularExpression: /[0-9A-F]+/ }
}

정규 표현식의 몇 가지 예가 더 있습니다:

  • 쉼표로 구분된 1~3개의 위치가 있는 숫자 목록입니다:
    /\d{1,3}(?:,\d{1,3})+$/
  • 소수점 앞에 최대 3개의 숫자와 소수점 뒤에 1~2개의 숫자로 구성된 금액:
    /(\d{1,3})([.,]\d{1,2})?$/

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.