Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Variable in a QRegularExpression?

    General and Desktop
    2
    2
    247
    Loading More Posts
    • 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.
    • I
      igor_stravinsky last edited by

      Is it possible to construct a QRegularExpression that includes a variable? I'm not seeing any examples.
      e.g.

      QString myVariable = "bar"
      QRegularExpression re ("^foo.* myVariable$")
      
      Pablo J. Rogina 1 Reply Last reply Reply Quote 0
      • Pablo J. Rogina
        Pablo J. Rogina @igor_stravinsky last edited by

        @igor_stravinsky what about constructing the pattern before and using setPattern() method to apply it? pseudo-code:

        QString myVariable = "bar";
        QString myPattern = "^foo.*" + myVariable + "$";
        QRegularExpression re;
        re.setPattern(myPattern);
        

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 3
        • First post
          Last post