Find strings between two tags with regex in Qt

前端 未结 1 516
旧巷少年郎
旧巷少年郎 2021-01-21 19:27

can anybody help me with this?

I have a string which contains N substrings, delimited by tags and I have to get ALL of the substrings. The string is like

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-21 19:57

    Use rx.setMinimal(true) with .* to make it lazy:

    QRegExp rx("START.*END");
    rx.setMinimal(true);
    

    See the QRegExp::setMinimal docs:

    Enables or disables minimal matching. If minimal is false, matching is greedy (maximal) which is the default.

    0 讨论(0)
提交回复
热议问题