Closed popu2do closed 7 months ago
If you want to match the entire string you can use parse
instead of search
, the prefix can be discarded:
>>> result = parse(
... format="{x} auto expo center 20px mean = {AEB}",
... string="xxx auto expo center 20px mean = [6798, 5486]",
... )
>>> result.named["AEB"]
'[6798, 5486]'
The behavior of search does not seem like a bug to me. This function searches a string for the first occurrence of the format, and without any other constraints, the non-greedy result you see capturing a [
is indeed the first occurrence.
parse: 1.20.1 python: 3.9.13
As you can see,AEB doesn't seem to be handled correctly, I think that this is a bug? my interim solution is end of line append tag to avoid bug,
Is there a better way?