Remove string from QStringList with higher number
-
I have some elements in QString List as below
Test_String1-1
Test_String2-2
Test_String1-2
Test_String1-3
Test_String2-10
Test_String3-1
Test_String4-1
Test_String3-3I need to remove all the string with lower end number for example only string with name
Test_String1-<number> with highesht number should be in list and rest other lower number should be removedso output should be in QStringList should contain only below elements
Test_String1-3
Test_String2-10
Test_String3-3
Test_String4-1Please suggest how to do this
-
I have some elements in QString List as below
Test_String1-1
Test_String2-2
Test_String1-2
Test_String1-3
Test_String2-10
Test_String3-1
Test_String4-1
Test_String3-3I need to remove all the string with lower end number for example only string with name
Test_String1-<number> with highesht number should be in list and rest other lower number should be removedso output should be in QStringList should contain only below elements
Test_String1-3
Test_String2-10
Test_String3-3
Test_String4-1Please suggest how to do this
Is this a coding issue or are you looking for an algorithm, which will filter your
QStringList
?If all your strings have this structure (one number before and one number after a
'-'
), you can separate the strings and compare each 'group' to get the highest final digit of e.g.String3
- group. -
@Pl45m4 I am looking for algorithm. Can you please help ?
-
@Ayush-Gupta said in Remove string from QStringList with higher number:
I am looking for algorithm. Can you please help ?
@Pl45m4 already told you how to do it.