[Solved]Wrong QRegExp
-
Hellow, i have this code:
@ QString str = "asin(";
str.replace(QRegExp("[^a]{0,1}sin\("),"yes!");
qDebug() << str;@
And i get "yes!", why is it happened?
In advance thank for your help! -
Your reg exp is saying match everything where there is everything except for an a one or zero times before the sin.
-
How can i changed it, on the this site http://gskinner.com/RegExr/ all worked ok, why it is hapanned?
-
You should have "ayes!" based on this regexp. Are you sure you have "yes!" only?
-
Sorry, but i do not fully understand what you said, this is full code whitch i used
@QString text = lineEdit->text();
// text, for example = "asin", and after replace it should be = "asin"
text.replace(QRegExp("[^a]{0,1}sin\("),"Math.sin(");@ -
[quote author="Ruzik" date="1313230274"]How can i changed it, on the this site http://gskinner.com/RegExr/ all worked ok, why it is hapanned?[/quote]
"No it didn't":http://regexr.com?2uer8
Just remove the {0,1} to make it work. However this will also select the character before the sin(. May I suggest something like \bsin( or usage of subexpressions. -
Ok, thank you for help!