이 페이지에서

RegularExpressionValidator QML Type

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

Import Statement: import QtQuick
In C++: QRegularExpressionValidator

속성

상세 설명

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

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})?$/

© 2026 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.