如何在 Qt QML 中断行源代码

问题描述 投票:0回答:1

我需要打破Qt QML源文件中的长正则表达式,例如:

TextInput {
  ...
  validator: RegExpValidator {
    regExp: /Here goes a very long regular expression. I want to break it to multiple lines/
  }
}

我怎样才能做到这一点?

regex qt syntax qml
1个回答
0
投票

这是一个五年的问题。但是,以防万一有人仍然想知道如何在 JavaScript 中将长正则表达式拆分为多行?它可以通过 JavaScript QML 语法以多种方式解决,包括:

TextInput {
        color: "red"
        text: "44444AAAAAA"
        id: userinput
        validator: RegularExpressionValidator {
            regularExpression: new RegExp(
                                   /[0-9]+/.source
                                   +/[A-Z]+/.source
                                   )
        }
        onAccepted: {
            console.log("valid input");
            text:displayText
        }
    }
© www.soinside.com 2019 - 2024. All rights reserved.