Reputation: 303
I have extracted the following sentence :
Very important point. It should be discussed in our next meeting.
from the following line:
ID: 1 x: 1202 y: 2453 w: 242 h: 459 wn: 13 ln: 12 c: Very important point. It should be discussed in our next meeting.
using this QRegularExpression:
regularExpression.setPattern("(?<=\\s)c:\\s?(.*)$");
However, the output is:
Very important point. It should be discussed in our next meeting.\r
The presence of the \r is quite normal because the line I am working with is written in a text file (Windows 8.1 Operating System).
Do you know how to extract the sentence without having the "\r" in the resulting output ? I really have no idea.
Thank you so much for your help
Upvotes: 1
Views: 167
Reputation: 627087
You can achieve that using a negated character class [^\r\n]
:
regularExpression.setPattern("(?<=\\s)c:\\s?([^\r\n]*)");
^^^^^^^^
The [^\r\n]*
subpattern matches zero or more characters other than \r
and \n
.
Upvotes: 2