正则表达式将多行上的源代码展平为一行

时间:2015-09-28 09:10:01

标签: regex qt qml

要重新格式化一些代码(Qt QML)我试图实现从此开始

SomeOuterTag{

    TableViewColumn {
            role: "property1"
            title: "property1"
    }

    TableViewColumn {
            role: "property2"
            title: "property2"
    }

}

SomeOuterTag{ 
    TableViewColumn {role: "property1"; title: "property1"}
    TableViewColumn {role: "property2"; title: "property2"}
} 

我正在尝试使用正则表达式和替换(sublimeText / Perl兼容的正则表达式引擎)实现此目的。

我设法匹配包含在Generic标签中的字符串,但不是如何#34; unwrap"这条线。

初始版本:https://regex101.com/r/gI0xC3/25

[更新1]

在评论中提出的这个版本(stribizhev)做了我要求的,但是当有许多不同于2的属性时没有概括。

正则表达式:https://regex101.com/r/gI0xC3/27

0 个答案:

没有答案