Search code examples
c++qtqstring

Showing sub string after specific character


I want to show sub string after "<". for example I have this statements:

input:

" o <kpl"  

output:

"<kpl"

input:

"h123 l<"

output:

"<"

How to do that?


Solution

  • You can use mid() for that:

    QString input = "h123 l<";
    int index = input.indexOf('<');
    if (index  != -1)
    {
        QString output = input.mid(index);
    }