I have the string "pid:8792 byr:2000 cols:hkjdp\n"
and I only want to extract the number after the byr:
. I thought that it could be done with extracting a formatted string with sscanf(str,"byr:%d",&number);
. But unfortunately you can't do that since there are other characters before and after the number so I saw that you could use some sort of regex like in this question asked How to use regex in sscanf
so I tried something like this: sscanf(passport, "%*[^byr:]:%[^\h]%*[^\n]", byr);
where byr is now defined as char *byr;
. But you can't use regular regex expressions like \h
for whitespace for example.
Long Story short: Is there any way for me to parse many strings using sscanf
and always extract that number after byr:
and where can I find a cheatsheet for all those characters to use in a formatted string? (Of course I know about the obvious %f %d %s %c
and so on but these dont really do much in this case.