PDA

View Full Version : QRegExp to match strings within ' and also containing '



Morea
20th September 2009, 20:00
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

Lykurg
21st September 2009, 07:30
where is your exact problem? You could use ('[^']{1}|[^']{1}'$) for matching the end of your replacement. Similar for your beginning.