python - Regexp extract XML attribute value -


please, advice how xml attribute value regexp python style.

here example, extract has full match(long story)

<method code="abc"> 

the achieved (?<=code=\")(.*?)(?=\">), ignores method part @ all

thanks

well, either learn basics of regex syntax , use re, or have @ python's xml.etree.elementtree module parse xml directly.

if want go regex, can test language-specific expressions interactively online tools, regex101 example.

maybe <(?p<method>\w*?) (?p<code>\w*?)=\"(?p<value>.*)\"> job. once again, mentioned, extracting data xml using regex fragile , limited.


edit: clearer explanation 3

edit2: add regex suggestion


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -