parse logo parse: findall

1 2 3 4 5
Notes

There's one edge-case to still consider. What do we do if there's multiple strings that match to our format? Even if we use search we'll only find one match.

from parse import search

fmt = "https://github.com/{account}/{project}/"
txt = "https://github.com/koaning/human-learn/ https://github.com/koaning/scikit-lego/"

# This only returns one result.
search(fmt, txt)

Instead, you'll want to use findall.

from parse import findall

fmt = "https://github.com/{account}/{project}/"
txt = "https://github.com/koaning/human-learn/ https://github.com/koaning/scikit-lego/"
res = findall(fmt, txt)

# This returns two results
list(res)