Regular Expression not working!
-
I have tried using this negative lookahead ".(?![a-z])" to split sentences based on the match - "dot, not followed by any characters in "a-z". It doesn't seem to work as this whole string is being considered as the pattern rather than the desired set. Please help!!
-
bq. Note: The C++ compiler transforms backslashes in strings. To include a \ in a regexp, enter it twice, i.e. \.
http://qt-project.org/doc/qt-4.8/qregexp.html#characters-and-abbreviations-for-sets-of-characters
-
Yes I I appreciate your help, Sirop. But, I have already tried almost everything before posting here, and unfortunately nothing works. Here's my snippet :-
QString st = "HELLO HOW ARE YOU.a THANK HOW YOU.2ELLO NOT YOU.";
QStringList ql = st.split("\.(?![a-z])");
qDebug()<< ql.at(0);OUTPUT: "HELLO HOW ARE YOU.a THANK HOW YOU.2ELLO NOT YOU"
-
Hi,
Double backslashes are needed because you are still writing a string, so you need escape the backslash properly in order to obtain the correct regexp. You can test and validate regular expressions for QRegExp with the regular expression example from Qt's sources.