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. Remove Parts of a String
Forum Updated to NodeBB v4.3 + New Features

Remove Parts of a String

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

    Hello again,

    im Looking to solve the fallowing, and i am Looking for ideas.

    The string Looks like: Eintrag_2 { ExternalWritable := 'False'} : Bool;

    and i want to remove { …} the curly bracket and everything between it. Does that just work with a parser or does the RegularExpressions have some Tools to do the Job?

    K 1 Reply Last reply
    0
    • M meikelneit

      Hello again,

      im Looking to solve the fallowing, and i am Looking for ideas.

      The string Looks like: Eintrag_2 { ExternalWritable := 'False'} : Bool;

      and i want to remove { …} the curly bracket and everything between it. Does that just work with a parser or does the RegularExpressions have some Tools to do the Job?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @meikelneit

      This is depending on the complexity of text between curled braces. However, I would try first with QRegularExpression.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • M Offline
        M Offline
        meikelneit
        wrote on last edited by
        #3

        If someone wants to do the same, i did it with the fallowing Code:

        int l_indexAnfang, l_indexEnde, l_deleteWeite;
        l_indexAnfang = p_String.indexOf(QRegularExpression("{"),0);
        l_indexEnde = p_String.indexOf(QRegularExpression("}"),0);
        l_deleteWeite = l_indexEnde - l_indexAnfang + 1;
        p_String = p_String.remove(l_indexAnfang, l_deleteWeite);

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4

          p_String.replace(QRegularExpression(QStringLiteral("{.*}")),QString());

          https://doc.qt.io/qt-5/qstring.html#replace-12

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          5
          • M Offline
            M Offline
            meikelneit
            wrote on last edited by meikelneit
            #5

            Evene better. What is the Macro inside the Expression good for?

            Does this just "create" the string while compiling so it hasnt to be created in the runtime anymore?

            VRoninV 1 Reply Last reply
            0
            • M meikelneit

              Evene better. What is the Macro inside the Expression good for?

              Does this just "create" the string while compiling so it hasnt to be created in the runtime anymore?

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              @meikelneit said in Remove Parts of a String:

              Does this just "create" the string while compiling so it hasnt to be created in the runtime anymore?

              https://woboq.com/blog/qstringliteral.html

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              3
              • M Offline
                M Offline
                meikelneit
                wrote on last edited by meikelneit
                #7

                Thank you very mutch.

                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