Hi!
Imagine i want to replace all occurrences of "textA" by "textB" in "str".
(QString str, textA, textB; )
Is there a function for this or i must create a loop and replace until no more occurrences found?
Thanks
Hi!
Imagine i want to replace all occurrences of "textA" by "textB" in "str".
(QString str, textA, textB; )
Is there a function for this or i must create a loop and replace until no more occurrences found?
Thanks
Take a look at QString::replace() docs and read what it does.
J-P Nurmi
Didnt you have a look at QString::replace ??
Yeap ... missed that one.
Thanks
PS: Promisse i will look carefully before posting nest time
QString & QString::replace ( const QString & before, const QString & after, Qt::CaseSensitivity cs = Qt::CaseSensitive )
This is an overloaded member function, provided for convenience.
Replaces every occurrence of the string before with the string after.
If cs is Qt::CaseSensitive (the default), the search is case sensitive; otherwise the search is case insensitive.
Example:
QString str = "colour behaviour flavour neighbour";
str.replace(QString("ou"), QString("o"));
// str == "color behavior flavor neighbor"
Note: The replacement text is not rescanned after it is inserted.
Example:
QString equis = "xxxxxx";
equis.replace("xx", "x");
// equis == "xxx"
Bookmarks