View Single Post
Old 08-10-2019, 09:43 AM   #28
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,709
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
You would only have to do two checks if you didn't know what you were looking for. Otherwise, you simply search for what matters ... regardless of position.

If a meta tag with the name "xyz" is what you need to find, then you use a regex that doesn't care in what order the name attribute appears:

Code:
<meta[^>]*(?=name=\"xyz\")[^>]*>
If it's the content attribute that you're looking to match, then its:
Code:
<meta[^>]*(?=content=\"123\")[^>]*>
Not trying to discourage you from using bs4/lxml for pure xml, just trying to point out that unless you've got a lot of complicated metadata editing to do, a simple find and replace could turn out to be much simpler and use less lines of code.
DiapDealer is online now   Reply With Quote