I am going to use regular expressions in a C++ application, but I am not experienced in regex. I want in particular to check a number of strings if they belong to one of the following categories:
X.anystring -> X must be necessarily and exclusively letter (not digit).
XY.anystring -> X, Y must be necessarily and exclusively digits 0-9 (not letters).
How can I check them using regex? What tutorial for regex could you recommend in order to acquaint me with regex?
Seriously, regexp:s are not the right solution for you in this case.
To start with, regexp:s are not part of the C++ language so you will need to use a specific regexp library. (C++11, whoever, include support for regexp:s.)
Secondly, both your use cases can trivially be encoded in plain C++, all you need to do is to loop over the characters in the strings and check if each of them match your requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With