r1chardj0n3s / parse

Parse strings using a specification based on the Python format() syntax.
http://pypi.python.org/pypi/parse
MIT License
1.72k stars 101 forks source link

Potentially unexpected behaviour with "=" character #106

Closed s16h closed 4 years ago

s16h commented 4 years ago

Is it expected that parse("b={}", "ab=cd") is None? I was expecting to get <Result ('cd',) {}>.

vladikcomper commented 4 years ago

Did you mean parse("ab={}", "ab=cd")? Because your expression and the string do not actually match. If you're trying to match any characters at the beginning of the string, before the ...b= part, you might be looking for something like this:

>>> parse("{}b={}", "ab=cd")
<Result ('a', 'cd') {}>
r1chardj0n3s commented 4 years ago

Or you could use search to find your parse pattern inside a larger string. Either way, looks like this report may be closed.

s16h commented 4 years ago

Thanks for the clarification. I has misunderstood.