If you want to implement it, the final state machine would be just fine. For example:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define FSM
#define STATE(x) s_##x :
#define NEXTSTATE(x) goto s_##x
int test_input(const char *str) {
if (strlen(str) != 6)
return 1;
FSM {
STATE(q0) { /* first digit */
if (isdigit(*str++)) NEXTSTATE(q1);
else return 1;
}
STATE(q1) { /* second digit */
if (isdigit(*str++)) NEXTSTATE(q2);
else return 1;
}
STATE(q2) { /* dot */
if (*str++ == '.') NEXTSTATE(q3);
else return 1;
}
STATE(q3) { /* third digit */
if (isdigit(*str++)) NEXTSTATE(q4);
else return 1;
}
STATE(q4) { /* fourth digit */
if (isdigit(*str++)) NEXTSTATE(q5);
else return 1;
}
STATE(q5) { /* fifth digit */
if (isdigit(*str)) return 0;
else return 1;
}
}
return 0;
}
int main(void) {
char *input1 = "38.901";
char *input2 = "38,901";
int retval = test_input(input1);
printf("%s\n", (retval)?"fail": "ok");
retval = test_input(input2);
printf("%s\n", (retval)?"fail": "ok");
return 0;
}
There is formal theory for transforming regular expressions into finite state machines, but I think this would be too complex for you. If you are parsing some more complicated input and if you do that often, you should learn EBNF form and learn some parser generator like Bison (C, C++), Parsec or Happy (Haskell) and so on.