fix bug 1412

for example

str_match(".png.3", "%{.png|.txt}%.{one|two}");

function into an infinite loop

- while (*fmt && fmt[-1] != '|' && fmt[-1] != '}')
+ while (*fmt && *fmt != '|' && *fmt != '}')
+ fmt++;
+ if (*fmt == '|' || *fmt == '}')