mardi 29 mars 2022

RegEx: how to batch delete virtual keyword in derived method by Regex?

I'm trying to delete the virtual keyword in the derived method which is an override. Should I use virtual, override, or both keywords?

now I have the several scenario:

virtual void test1() const override;

virtual int test2() override { xxx }

virtual void test3(int p1,
                    int p2,
                    int p3) const override;
virtual void test4(int p1,
                    int p2,
                    int p3,
                    int p4) const override;

virtual void testn(int p1,
                    int p2,
                    int p3,
                    int p4,
                    ......,
                    int pn) const override;

--> I need to delete the virtual keyword for the whole project code(hundreds of files)

void test1() const override;

int test2() override { xxx }

void test3(int p1,
                    int p2,
                    int p3) const override;
void test4(int p1,
                    int p2,
                    int p3,
                    int p4) const override;

void testn(int p1,
                    int p2,
                    int p3,
                    int p4,
                    ......,
                    int pn) const override;

Because there are lots of places that need to modify, I plan to use RegExp to do it. I try the following RegExp:

\bvirtual\b.*\s.*\s.*\s.*\s.*\s.*\s.*\boverride\b

but it seems \s.* need to know the number, is there anyone familiar with RegExp who can help me how to write the expression? and also how to replace and delete the virtual keyword by RegExp? enter image description here

Aucun commentaire:

Enregistrer un commentaire