Useful Regular Expressions

Well, I am regularly typing searches over and over in Visual Studio search. Oddly, it's because I'm lazy. I could just search through my history, but why bother when I can just type it again.

Here are some of my favorites :

Speedily convert read properties from a class into code without having to cut and paste each one or type each return value in.

For example :

    bool enablePathelogicalPattern() const

Becomes :

    bool enablePathelogicalPattern() const { return m_enablePathelogicalPattern; }

The search pattern is :

  ^[a-zA-Z0-9]+[ \t]+{[A-Za-z0-9]+}\(\)[ \t]+const

and the replace pattern is :

  \0 { return m_\1; }

Convert member variables into inline property readers

For example :

    quint32 m_lineInterrupt1;

Becomes :

    inline quint32 lineInterrupt1() const { return m_lineInterrupt1; }

The search pattern is :

    {[a-zA-Z0-9_]+}[ \t]m_{[a-zA-Z0-9]+}\;

The replace pattern is :

    inline \1 \2() const { return m_\2; }