Uh ... The best way is
#include <regex.h>
This is the standard POSIX standard regexp API .
For systems other than POSIX, using your own alternative is one alternative; the basic regular expression mechanism is not so difficult to implement. I am sure that there are ready-made solutions too, I did not do this.
Think about it, I think glib has one.