Macro sscanf::scanf_unescaped[][src]

scanf_unescaped!() { /* proc-macro */ }

Same as scanf, but allows use of Regex in the format String.

use sscanf::scanf_unescaped;
let input = "5.0SOME_RANDOM_TEXT3";
let output = scanf_unescaped!(input, "{}.*{}", f32, usize);
assert_eq!(output, Some((5.0, 3)));

The basic scanf would escape the . and *and match against the literal Characters, as one would expect from a Text matcher:

use sscanf::scanf;
let input = "5.0SOME_RANDOM_TEXT3";
let output = scanf!(input, "{}.*{}", f32, usize);
assert_eq!(output, None); // does not match

let input2 = "5.0.*3";
let output2 = scanf!(input2, "{}.*{}", f32, usize);
assert_eq!(output2, Some((5.0, 3)));

Note that the {{ and }} Escaping for literal { and } is still in Place:

use sscanf::scanf_unescaped;
let input = "5.0 } aaaaaa 3";
let output = scanf_unescaped!(input, r"{} \}} a{{6}} {}", f32, usize);
  // in regular Regex this would be   ...  \} a{6} ...
assert_eq!(output, Some((5.0, 3)));

Also Note: ^ and $ are added automatically to the start and end.