Sign in to follow this  
Thirthe

[C/C++] reserved keywords and regex

Recommended Posts

Thirthe    128
hello, i've gotten an assignment of matching some patterns, and whilst i solved the rest of the assignment, i'm stuck at the easiest part of it - matching C and C++ reserved keywords. when i run it through the system that checks whether i passed the assignment or not it said that my regex only matched in 72 out of 77 cases. so now i'm asking.. which reserved keywords have i forgotten? i've used the list here: http://lib.daemon.am/Books/C/apb/apb.htm shouldn't this be correct:
\<(catch|inline|template|class|new|this|delete|operator|throw|except|private|try|finally|protected|virtual|friend|public|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\>

note: i'm doing this in OpenOffice, so there are some minor differences. \< equals ^ \> equals $

Share this post


Link to post
Share on other sites
Ra    1062
It looks like you're missing namespace, typename, mutable and explicit.

(Oh, and except and finally aren't keywords in C or C++.)

You also forgot the casts: static_cast, const_cast, dynamic_cast, and reinterpret_cast.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this