we know that Arduino is using C++ under the hood, we never know exactly how much of it is actually allowed/supported. For instance, using std C++ strings (not C) is probably not recommended. It's rather unclear what subset of C++ is allowed and the official description on Arduino's website doesn't help much.
The C++ compiler will certainly tell you when you use something not supported. A range based for loop has been around for a long time (C++11?), and can certainly be used here. There is also nothing preventing standard library replacements, since you have the same underlying language the standard library writer does. There is no standard library strings for avr (arduino does their own version), but its not needed in this case. The array of const char pointers is nothing special, and a range base for loop can easily iterate through those pointers.
The C++ language is always available when using a C++ compiler, regardless of whether you use a standard library (if available). I use C++ all the time, no C++ standard library. If you use arduino, no reason to leave all the C++ features on the shelf. You are 'allowed' to use anything the compiler version allows (gcc 7.3.0 = c++17), and arduino has no say in what you 'may' use.
You can simulate this code for a pc, where the online compiler will produce output you can read-
https://godbolt.org/z/MsE31q5b9The arduino Serial class is simulated, so you have to provide a (read) string to it when creating the Serial1 instance. Change the string to see different results. Instead of strcmp, strcasecmp was also used so case can also be different.
Another version where you can set the 'read' string at runtime to test various numbers-
https://godbolt.org/z/3Kozxbba3(the print output is in the right panel)
I ran code and check tag but doesn't print anything
That code was using Serial in a few places where Serial1 should have been used, which was a mistake.