Skip to content

Search for a certain pattern error at the end of a string #190

Answered by wimglenn
popu2do asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wimglenn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #182 on August 21, 2024 16:01.