how do I test the format of a string?
Im having trouble matching the format of a string, the format is that of the .srt timing which is "00:00:01,000 --> 00:0开发者_如何学Go0:04,000", hour,minutes,seconds,mili seconds.
how do I match this in a string? Im trying to add and subtract the time here.
To perform arithmetic on the time values, you'll want to convert the string representations to integer values.
You can use sscanf
to read the numbers from the formatted string, then multiply them together appropriately to get a millisecond value. sscanf
returns the number of matches that succeeded, so if the integer value returned is less than the number of fields you expected to match, you know the string doesn't match your input format.
I think sscanf is what you need
精彩评论