Qt Forum

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

    QRegExp and *literal* Minus/Dash

    General and Desktop
    1
    1
    667
    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.
    • M
      MuldeR last edited by

      How do I match a literal Minus/Dash in QRegExp?

      My goal is to match a literal character, delimited by word boundaries.

      This works as expected, to match a literal x:
      @QRegExp test("\bx\b");@

      But neither of these works to match a literal "-" character:
      @QRegExp test1("\b-\b");
      QRegExp test2("\b(-)\b");
      QRegExp test3("\b\-\b");
      QRegExp test4("\b(\-)\b");@

      I think "-" shouldn't need escaping, but I tired with and without. No luck.

      How do I do it correctly?

      Thanks!

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

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