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. Variable in a QRegularExpression?

Variable in a QRegularExpression?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 402 Views
  • 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 Offline
    I Offline
    igor_stravinsky
    wrote on last edited by
    #1

    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. RoginaP 1 Reply Last reply
    0
    • I igor_stravinsky

      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. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @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
      3

      • Login

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