Results 1 to 2 of 2

Thread: QRegExp to match strings within ' and also containing '

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QRegExp to match strings within ' and also containing '

    Hi, how do I write a regexp that will match strings starting with ' and ending with ' and the strings may any even number of ' chars. For example
    'how '''' to s''olve'' this?'

    is a valid string. A line might also contain many of these strings, so setMinimal(true) might be good to add ?

    I intend to do string replacement, so the complete line:

    foo 'Gandalf ''the grey' became 'Gandalf the'''' white' bar

    should be
    foo REPLACE became REPLACE bar

  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: QRegExp to match strings within ' and also containing '

    where is your exact problem? You could use ('[^']{1}|[^']{1}'$) for matching the end of your replacement. Similar for your beginning.

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.