I am writing a C++ program. I have an array of char array trans[20][100]. Actually each string of trans is a transition of a grammar(Programming language translators). I want to check for each string in trans whether there is a Non-terminal after a '.' i.e. i want to check if in the strings there is a '.' followed by any capital letter. Can anyone please tell me how to do it??
-Thanks in advance
Identifying the next character in a string is capital or not
2.4k views Asked by Antrromet At
3
There are 3 answers
1
On
You can use any RegExp library (e.g. this one). The test regular expression is /\.[A-Z]/
.
Or for ASCII string you can use:
int strHasDotCap(const char *s)
{
while (*s) {
if (*s++ == '.') {
if (*s >= 'A' && *s <= 'Z') return 1;
}
}
return 0;
}
If you operate on ASCII char, then you could test if the int value of the char is between 65 and 90. See the ASCII table.