QString - secondIndexOf
-
I'm trying to get the second index of a character (;) in QString, but the only voids I'm aware of are
Qstring.indexOf()
andQString.lastIndexOf()
.
Is there any way to find the second index of a semicolon?
For example, Qstring is: file001;15-02-2019;Accounting;Management; .
I'm trying to get the index of 2nd semicolon (the one after 2019). How is that possible? -
I'm trying to get the second index of a character (;) in QString, but the only voids I'm aware of are
Qstring.indexOf()
andQString.lastIndexOf()
.
Is there any way to find the second index of a semicolon?
For example, Qstring is: file001;15-02-2019;Accounting;Management; .
I'm trying to get the index of 2nd semicolon (the one after 2019). How is that possible?@jellyv indexOf() excepts a start index as 2nd parameter and the documentation shows it
https://doc.qt.io/qt-5/qstring.html#indexOfso
int firstIndex = myString.index(';'); int 2ndIndex = myString.index(';',firstIndex+1);
that said, what do you want to do with the index. If you want to extract the strings between ';'
you could use
split
orsplitref
for example. -
@jellyv indexOf() excepts a start index as 2nd parameter and the documentation shows it
https://doc.qt.io/qt-5/qstring.html#indexOfso
int firstIndex = myString.index(';'); int 2ndIndex = myString.index(';',firstIndex+1);
that said, what do you want to do with the index. If you want to extract the strings between ';'
you could use
split
orsplitref
for example. -
@jellyv indexOf() excepts a start index as 2nd parameter and the documentation shows it
https://doc.qt.io/qt-5/qstring.html#indexOfso
int firstIndex = myString.index(';'); int 2ndIndex = myString.index(';',firstIndex+1);
that said, what do you want to do with the index. If you want to extract the strings between ';'
you could use
split
orsplitref
for example.