更新时间:2023-02-21 12:34:32
正则表达式不必是完美的,只要它能捕获大多数情况。/.* class\s +([^ {] +)\s * [:]?([^ {] +){/
pre>这应该适用于大多数类定义,包括模板类。类名称捕获在$ 1中,如果它是派生类,则基数将为$ 2。
I need a regular expression for finding class declarations so I can add a #define before the "class" keyword. The regular expression doesn't have to be perfect, just good enough that it catches most of the cases.
/.*class\s+([^{]+)\s*[:]?([^{]+){/
This should work for most class definitions, including template classes. The class name is captured in $1 and if it is a derived class, the base will be in $2.