TextScanner

Author: KeliHlodversson

=Description= This is a reimplementation of the sscanf C standard library function for .Net, which can be very handy for parsing data in strings without needing to write your own parsers and suchlike.

=Usage= The format string is similar to the one accepted by the C standard library functions:

%% skips a % litteral %d matches any optionally signed decimal number %o matches any optionally signed octal number %x matches any optionally signed hexadecimal number %i matches any optionally signed integer. If prefixed with 0, it's parsed in base 8 and 0x, base 16, else base 10 %u is an unsigned integer. %f float %s word - matches up to the next whitespace %c a list of characters. If no size is specified only 1 character will be matched %n returns an int containing the number of characters consumed sofar does not consume characters from the text string and ignores any flags except *. any other text is matched verbatim You can add extra options between the % sign and the format specifier: *   - the matching data will be ignored hh  - tiny size, the parsed data will be returned as a SByte (or Byte for %u) h   - half size, the parsed data will be returned as a Int16 (or UInt16 for %u,             System.Single for %f, the default) l   - long, the default for ints. Results in an Int32 (UInt32 for %u,            System.Double for %f) ll,L - long long. Results in an Int64 (UInt64 for %u, System.Decimal for %f)

You can also specify the maximum number of characters to match after the % sign, default is Infinite, except for %c, which is 1. Whitespace at the start of each pattern is skipped, except for %c. The Scan method will return a list of matched values. It will stop at the first pattern that fails to match and return any previously matched patterns. See the man page for sscanf(3) for more information on the original.

=TextScanner.cs=