[Qt-interest] QRegExp and tab-delimited text

Robert Hairgrove evorgriahr at hispeed.ch
Mon Feb 7 12:15:41 CET 2011


I'm trying to auto-detect tab-delimited text and am having trouble with
the simplest of regular expressions:

    //-------------------------------
    // This doesn't work:
    //-------------------------------
    QRegExp xx("*[\\t]*");
    QRegExp yy("*[\\t][\\t]*");
    int fa = xx.indexIn(first_row);
    int fb = yy.indexIn(first_row);
    //-------------------------------
    // This works:
    //-------------------------------
    int f1 = first_row.indexOf('\t');
    int f2 = first_row.indexOf("\t\t");
    //-------------------------------
    if ((f1>=0)||(f2>=0)) {
    // etc.

Can anybody point out the obvious to me, please?





More information about the Qt-interest-old mailing list