Results 1 to 5 of 5

Thread: QRegExp

  1. #1
    Join Date
    May 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QRegExp

    Hi!

    I have QStringList genreItems which is list of music genres. I want to find index of genre "Rock", but I get other genre witch got "rock" in its name (Classical Rock), but witch is before Rock genre.
    What should I do to find only element of list which is the same, not similar to my string?

    Qt Code:
    1. QRegExp rx(my_genre);
    2. int genrePosition = genreItems.indexOf(rx);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QRegExp

    Can you try:
    Qt Code:
    1. int genrePosition = genreItems.indexOf("Rock");
    To copy to clipboard, switch view to plain text mode 
    "And no one said 'don't use QPrinter to bake muffins'."

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QRegExp

    Try:
    Qt Code:
    1. QRegExp rx( "^" + my_genre + "$" );
    2. ...
    To copy to clipboard, switch view to plain text mode 
    Although according to the docs it shouldn't be necessary. Which Qt version do you use?

  4. #4
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QRegExp

    I second croland if what you want exact match i.e
    Qt Code:
    1. int genrePosition = genreItems.indexOf(my_genre);
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  5. #5
    Join Date
    May 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QRegExp

    All works fine :/ I missed that my parameter in QRegExp constructor has wrong value.
    Lot of work to do and not much sleep...eh...
    Sorry for trouble guys and thanks for help!

Similar Threads

  1. QRegExp Help
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2007, 00:13
  2. QRegExp progblem
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2006, 12:12
  3. QRegExp?
    By Marco812 in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2006, 08:31
  4. need help for my QRegExp
    By patcito in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 16:29
  5. Trouble parsing using simple QRegExp
    By johnny_sparx in forum Qt Programming
    Replies: 4
    Last Post: 24th February 2006, 00:42

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.