PDA

View Full Version : Finding LFs with QRegExp



Magu
8th June 2011, 12:27
Hi all,

I need to implement a "Find" menu as usual (press Ctrl+F ;) ), using QRegExp.
Its easy, also highlighting matches, but I have a (newbie) little problem with LF character. I think I am missing something, for example:

Text to find:

Version S98135-B Linked on
>> >>
>>
>>
...

If I look for an expression as "\t>>", QRegExp finds a tabulator and two extra chars (>>) as requested, but if I look for "\n>>" QRegExp doest not found nothing and returns FALSE. Also, these expressions fails:
"\\n"
"\x000A"
"\x000D\x000A"
"\r\n"
(I know, all of them are the same, and due to this is a Unix system, CRLF has no sense).

What am I doing wrong?

SixDegrees
8th June 2011, 13:27
In general, REs don't span multiple lines. You should reformulate your matching parameters to accomodate this and search only on a single line. There is no difference between a psuedo-string that 'ends' with '\n>>' and an actual string that begins with '>>', which is easily matched with '^>>'.

Magu
9th June 2011, 08:30
Newbie for Qt and Regexps ;)

Thanks for your reply