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] How to extract a Substring from a String using a Regular Exppression?
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to extract a Substring from a String using a Regular Exppression?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 6.5k 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.
  • D Offline
    D Offline
    dvillalobos
    wrote on last edited by
    #1

    Hi all,

    I have the following text:

    DROP TRIGGER IF EXISTS Text1.Text1 or DROP TRIGGER IF EXISTS Text1

    And what I need it to extract the Text1 or the Text1.Text1 part using a Regular expression.

    Any idea?

    Best regards.

    Regards

    David

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

      This link helps:

      http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=208&key=QRegExpExtractIPs#.T-3GiLQtjmE

      Regards

      David

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dvillalobos
        wrote on last edited by
        #3

        Hi,

        Here is how I resolved the problem:

        @

        QRegExp [removed]"^CREATE.(TABLE |TABLE IF NOT EXISTS |VIEW |DATABASE |PROCEDURE |FUNCTION |TRIGGER |EVENT ).[A-Za-z_\\d%]*\.{0,1}[A-Za-z_\\d%]*{0,1}");
        expression.indexIn(line);
        QRegExp expression2("[A-Za-z_\\d%]*\.[A-Za-z_\\d%]*");
        expression2.indexIn(line);
        symbolName = expression2.capturedTexts().at(0);
        if (symbolName.isEmpty()) {
        QRegExp expression3("[A-Za-z_\\d%]*");
        expression3.indexIn(line);
        symbolName = expression3.capturedTexts().at(0);
        }
        symbolName = symbolName.replace("`", "");
        symbolsLineNumber.insert(symbolName, counter);
        listSymbols->addItem(new QListWidgetItem(QIcon(icon), symbolName));
        @

        Regards

        David

        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