Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QString find all occurrences by RegExp
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QString find all occurrences by RegExp

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tucnak
    wrote on last edited by
    #1

    Hi, devnet.

    I have a task to find all occurrences in QString with RegExp and pack them into QStringList.

    My current implementation of this problem is ugly and not Qt-way. I've also read documentation. There are nothing connected with it.

    I want to do it like this:
    @
    QString text = object->getString(RANGE_ALL);
    QString regexp = object->getRegExp();

    QStringList occur = text.findAllOccurrences(regexp);
    @

    I know that this code is wrong because QString does not have method findAllOccurrences(QRegExp&) but how can I do it in Qt-way.

    Thanks in advance.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      I think that QRegExp::capturedTexts () can help in this case

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tucnak
        wrote on last edited by
        #3

        Thanks, tass. It should be that I was finding!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved