Find QRegExp in the text
-
I find my mistake
@ if (!plainTextEdit->document()->find(QRegExp("\{ *\}")).isNull())
listWidget->addItem("empty stylesheet {it's empty!}");@
And code work, but it is not work with sign of new string(\n), how can i modif my QRegExp to my code work, i try@
QRegExp("\{[ \Z]\}"))
QRegExp("\{[ \Z]\}"))
@And instead Z i try use A
All does not work[EDIT: wrap your code!, Volker]
-
AFAIK you can apply a regular expression in a single text block only. That is you cannot use \n notation with your regexp. I remember that in my homework I had to break my expression to two expressions to do that. I didn't found a way to use a regexp with two paragraphs in QPlainTextEdit....
you can use "this tool":http://sourceforge.net/projects/regexer to test regular expressions in Qt.
-
-
The answers above explain a problem I came to ask about, so thank you. However, in the general case of a user-entered pattern I do not see any way of getting around this bad restriction.
Suppose the pattern (example from QRegExp documentation) is <b>.*</b>, this cannot succeed when the document is:
@
some text or <b>bold
text</b> other etc.
@You could examine the user's pattern and change it into:
@
<b>.$
^.</b>
@But that would fail for the case of <b>on one line</b> and also would fail for the case of a target spanning three or more lines. In short I see no work-around for the general case of patterns matching across multiple lines. Comment?