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. QRegExp use find forward slash(/) and backward slash(\)
Forum Updated to NodeBB v4.3 + New Features

QRegExp use find forward slash(/) and backward slash(\)

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.6k 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
    mathi77in
    wrote on 9 May 2012, 04:03 last edited by
    #1

    Hi

    I am using QRegExp for file path. I have 2 type of file path.

    1. c:\Test\test.txt
    2. D:/Test/test.txt

    i use QRegExp for first type. like @QRegExp rx("([a-z A-Z]:\\|\\\\)"); @

    how to write QRegExp for forward slash(/) file path?

    Regards,
    M.Mathivanan

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on 9 May 2012, 06:23 last edited by
      #2

      I never tried, but I guess escaping will do the trick @/@

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mathi77in
        wrote on 9 May 2012, 08:20 last edited by
        #3

        I tried not find the forward slash(/)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on 9 May 2012, 09:11 last edited by
          #4

          the forward slash / has no special meaning in regular expressions.
          @QRegExp rx("([a-zA-Z]:[\\/]|[\\/]{2})");@
          works for both backward and forward slashes. (Note I've removed the whitespace character from the drive letter)

          But beware, you should also allow unix paths like "/home/dermanu", so possibly group "[a-zA-Z]:" together and make it optional by appending a "?" character

          1 Reply Last reply
          0

          1/4

          9 May 2012, 04:03

          • Login

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