Thursday, March 24, 2011

QRegExp-Editor new RegExp Ui & howto deal with line breaks and spaces

In my previous post I presented the new RegExp Ui. Now I'm working on the behavior part. We all have seen and worked with long and intricate RegExp's. QRegExp-Editor main purpose is to ease the pain of dealing with RegExp's. With this in mind is obvious, at least for me, that QRegExp-Editor should allow the user to break complicated RegExp's into small ones, across multiple lines. The computed QRegExp should obviously not contain the line breaks. Take a look at the following screenshot:

And for white spaces ? How should QRegExp-Editor deal with it ? Just remove them all ?


  1. IMHO A whitespace is a legitimate charachter to be matched. The use of newlines is not possible in C++ strings so we don't match that and rather use them as a line separator. Removing spaces however would possibly confuse the user. Each line in the Pattern Edit should (in my opinion) be regarded the pendant of a c++ string enclosed in quotes on a line of it's own. Just as the C++ line would match a space if it was there, the same should be done in QRegExp. That's my personal view though.

  2. Yes, there is no doubt that a whitespace is a legitimate character to be matched. I would argue that using \s is more clearer than using the actual ' '.
    Personally I tend to no use the actual ' ' in QRegpExp's but other people might use it.

    The solution is to allow the user to choose the desired behavior. Adding an option to wipe all the characters that match QChar::isSpace() before sending it to evaluation make a lot of sense to me.

    What do you think about that ?

  3. I like that idea. It would also make it possible to use whitespaces in the regexp to visually separate portions of the regexp without affecting the results. And with the option offered to the user he can choose what he wants/prefers. I certainly like it.