using regex on bs4 to match ids
refactoring repeated code into functions