The previous version of sscanf had "p" to change the symbol used to separate tokens. This specifier still exists but it has been formalised to match the array and enum syntax. What was previously:
pawn Код:
sscanf("1,2,3", "p,iii", var0, var1, var2);
Is now:
pawn Код:
sscanf("1,2,3", "p<,>iii", var0, var1, var2);
The old version will still work, but it will give a warning. Enum specifications can include delimiters, and is the only time "<>"s are contained in other "<>"s:
pawn Код:
sscanf("1 12.0 Bob,c", "e<ifp<,>s[32]c>", var);
Note that the delimiter will remain in effect after the enum is complete. You can even use ">" as a specifier by doing "p<\>>" (or the older "p>").
When used with strings, the collection behaviour is overruled. Most specifiers are still space delimited, so for example this will work:
pawn Код:
sscanf("1 2 3", "p<;>iii", var0, var1, var2);
Despite the fact that there are no ";"s. However, strings will ONLY use the specified delimiters, so:
pawn Код:
sscanf("hello 1", "p<->s[32]i", str, var);
Will NOT work - the variable "str" will contain "hello 1". On the other hand, the example from earlier, slightly modified:
pawn Код:
sscanf("hello there>27", "p<>>s[32]i", str, var);
WILL work and will give an output of:
You can now have optional delimiters using "P" (upper case "p" to match other "optional" specifiers). These are optional in the sense that you specify multiple delimiters and any one of them can be used to end the next symbol:
pawn Код:
sscanf("(4, 5, 6, 7)", "P<(),>{s[2]}iiii", a, b, c, d);
This uses a "quiet section" to ignore anything before the first "(", and then uses multiple delimiters to end all the text.