Skip to content
  • 0 Votes
    14 Posts
    1k Views
    Christian EhrlicherC

    @Aramir said in QRegExp returning incorrect position due to codec ?:

    ve seen many SD cards/emmc die in ereaders (devices I'm aiming for) therefore I'm trying to lower the write operations on it in order to not reduce their lifetime. That's it I think it's worth the trouble to figure out a solution to this problem instead of creating more and more e-waste.

    Again a useless optimization due to a feeling. Optimize only when you can prove it's a problem and needs to be optimzied.

    You SD-Card has likely a sector size of 512 or 1024 bytes. On top of this your filesystem may use a block size up to 64kb (NTFS, ext4 use 4kb ). So when you even change single byte in your file which is less than the sector size or block size it will write the whole sector/block.
    It's just plain stupid and an over-complicating of things for nothing.

  • 0 Votes
    15 Posts
    1k Views
    Petross404_Petros SP

    @SGaist said in Regex doesn't seem to work with Qt:

    QRegularExpression::wildcardToRegularExpression is what you were looking for.

    I am afraid I can't use this function since it is very recent and compatiblity with Qt5.4 is needed. But thank you.

    @VRonin thank you too, your example was to the point. I will take a deeper look at what you did there. Thanks again.

  • 0 Votes
    12 Posts
    11k Views
    SGaistS

    One small note, you are wasting CPU cycle here. The QRegularExpressionMatchIterator returns only match objects that contains a match thus the if is useless.

  • 0 Votes
    4 Posts
    10k Views
    sierdzioS

    Sure, they are in the docs: http://doc.qt.io/qt-5/qregexp.html#code-examples

    indexIn() method should interest you in this case.

  • 0 Votes
    5 Posts
    2k Views
    VRoninV
    QRegularExpression rx("[A-Za-z0-9]*"); QRegularExpressionalidator *v = new QRegularExpressionValidator(rx, this); ui->LE_ObjectName->setValidator(v);
  • 0 Votes
    1 Posts
    580 Views
    No one has replied
  • 0 Votes
    5 Posts
    7k Views
    VRoninV

    @MarkoSan said:

    are there any solutions for current code?

    either you enclose the RegExp pattern in tr() and trust the translator to do the right thing or you declare

    private: const QString logTags[3];

    then in the constructor add the initialisation

    UeLogWindow::UeLogWindow(QWidget parent) : \\ ... other inits , logTags{tr("[INFO]"),tr("[WARNING]"),tr("[ERROR]")}

    (if you don't have access to C++11 functionality you should not declare const and initialise the members with the usual [] operator)

    this also simplifies a lot the switch(logEntryType) part

    to use them in the regular expression you then just have to call QRegularExpression::escape(). for example, ruleError.pattern=QRegExp("^\\[ERROR\\].*"); would become

    ruleError.pattern=QRegExp("^"+QRegExp::escape(logEntryType[2])+".*");

    Again, here I used QRegExp but you should REALLY use QRegularExpression especially if you expect a big number of matches

  • QRegExp not found

    Solved General and Desktop
    3
    0 Votes
    3 Posts
    3k Views
    cfdevC

    not the same (.*?) and (.*) I tested on QT4 and QT5

    Ok I found the solution with this regular expression:

    QRegExp regex("\\<date(:(.*))?\\>");
  • 0 Votes
    10 Posts
    5k Views
    TheBadgerT

    Reading that report and thinking about it it makes sense that it is not an actual bug.

    For [a-z] it should not be escaped, since you want to match all characters from a up to character z.

    For [a\-z] you want to match character a, or character hyphen or character z.

  • 0 Votes
    2 Posts
    905 Views
    JohanSoloJ

    What OS and Qt version are you using?
    On windows the end-of-line (EOL) marking is done by \r\n, although I'm not sure how it is done in the QPlainTextEdit class, but it may worth to give a try.

    IIRC QRegExp should be replaced QRegularExpression in recent code, but I don't think this is the problem.
    And I'm not sure about the regex you posted: the caret should negate the content of the class, therefore matching any character not being a number or a spacing, resulting in exactly the opposite.
    If you basically basically want to reject any string containing a letter, then you could try to reverse your regex to "[^a-z,A-z]+".

  • 0 Votes
    4 Posts
    2k Views
    SGaistS

    You're welcome !

    Sure thing

    Happy coding !

  • 0 Votes
    3 Posts
    2k Views
    K

    You are probably right. I have added a report on JIRA