Results 1 to 4 of 4

Thread: Can I use QRegExp to remove the extension of a file?

  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Can I use QRegExp to remove the extension of a file?

    Hi mates!

    Given a QString (c:\blabla\text.ico) I'd like to remove its extension (c:\blabla\text).
    That's pretty easy scaning the string till the dot and splitting it.

    My question is, is it possible to use QRegExp to do that?
    I ask this cause I read in docs that:
    "String Splitting: A regexp can be used to identify where a string should be split apart, e.g. splitting tab-delimited strings."

    But no idea about how to do it.

    Any idea?

    Thanks for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Can I use QRegExp to remove the extension of a file?

    I won't tell you how you can use a reg exp for that, because it is too heavy for a simple operation like that. Better use QString::lastIndexOf() with QString::chop().

  3. The following user says thank you to Lykurg for this useful post:

    ricardo (20th May 2009)

  4. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can I use QRegExp to remove the extension of a file?

    Last edited by nightghost; 20th May 2009 at 13:20.

  5. The following user says thank you to nightghost for this useful post:

    ricardo (20th May 2009)

  6. #4
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can I use QRegExp to remove the extension of a file?

    Very usefull, thanks a lot! I will use them instead a regular expresion.

Similar Threads

  1. QFileDialog and file extension
    By calhal in forum Qt Programming
    Replies: 3
    Last Post: 9th March 2010, 12:54
  2. Using QRegExp For File Filtering
    By QbelcorT in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2009, 09:02
  3. Remove Duplicate Lines in a file
    By nmuntz in forum Qt Programming
    Replies: 4
    Last Post: 12th January 2009, 00:04
  4. remove node in xml file
    By mattia in forum Newbie
    Replies: 1
    Last Post: 6th March 2008, 13:25
  5. QRegExp Help; remove all html tag
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 27th July 2006, 13:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.