[Plugin] Sscanf problem - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Plugin] Sscanf problem (/showthread.php?tid=1168) |
Sscanf problem - Pinch - 2020-08-27 Code: if(sscanf(inputtext, "{s[32]'@'s[32]'.'s[16]}")) Always positive, even if I enter something like [email protected] I'm using sscanf 2.10.2 RE: Sscanf problem - Tama - 2020-08-27 I think it's nearly impossible using only sscanf, you should replace '@' and '.' to space and check it like this: PHP Code: if (sscanf(inputtext, "{sss}")) Or you can just see my code below: https://gist.github.com/se8870/ca137f685298c06fea7d7abb861f2202 RE: Sscanf problem - Pinch - 2020-08-27 (2020-08-27, 09:10 PM)Tama Wrote: I think it's nearly impossible using only sscanf, you should replace '@' and '.' to space and check it like this: Nope, you cannot use s without length. I already fixed this but this is an sscanf bug I think idk why is search ' ' broken smh RE: Sscanf problem - Tama - 2020-08-28 (2020-08-27, 09:41 PM)Pinch Wrote: Nope, you cannot use s without length. Still work but you're get an error. That code it's just example for older version. RE: Sscanf problem - Pinch - 2020-08-28 I'm using sscanf 2.10.2 which turns warnings into errors... RE: Sscanf problem - Y_Less - 2020-09-23 Search works fine, but you don't want search. `s` can contain `@`, so if you type `[email protected]` sscanf will do the following: `s[32]` - Gathers everything until the first separator (whitespace by default), so `[email protected]`. `'@'` - Looks for another `@`, but there isn't one, so the check fails. You are missing up searches and delimiters. sscanf doesn't have look-ahead/look-behind, so while it is reading a string it doesn't know that the NEXT instruction is to look for an `@`. You've not told sscanf to stop reading strings at `@`, so it doesn't. You want: "p<@>s[32]s[32] " (you also don't want to check for a `.`, as valid e-mail addresses don't have to have one. Really all you want is `strfind(input, "@") != -1` - that's the simplest way to look for a valid e-mail address. Of course the only truly correct way is to send an e-mail it it. |