Чтобы извлечь наибольшую ширину, просто поместите вокруг нее max()
: -e 'max(extract(//@srcset,"(\d+w)",1,"*"))'
.
Чтобы извлечь URL с наибольшей шириной, сначала нужно разделить каждый URL:
$ cat <<EOF | xidel -s - -e 'tokenize(//@srcset,", ")'
<img srcset="https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-696x457.jpg 696w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-220x144.jpg 220w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-300x197.jpg 300w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-768x504.jpg 768w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-475x312.jpg 475w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-741x486.jpg 741w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-640x420.jpg 640w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu.jpg 800w" />
EOF
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-696x457.jpg 696w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-220x144.jpg 220w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-300x197.jpg 300w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-768x504.jpg 768w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-475x312.jpg 475w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-741x486.jpg 741w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-640x420.jpg 640w
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu.jpg 800w
Затем, к моему собственному удивлению, вы можете снова обернуть max()
вокруг него:
$ cat <<EOF | xidel -s - -e 'max(tokenize(//@srcset,", "))'
<img srcset="https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-696x457.jpg 696w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-220x144.jpg 220w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-300x197.jpg 300w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-768x504.jpg 768w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-475x312.jpg 475w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-741x486.jpg 741w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu-640x420.jpg 640w, https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu.jpg 800w" />
EOF
https://www.jewishpress.com/wp-content/uploads/Billionaire-Arnon-Milchan-and-PM-Benjamin-Netanyahu.jpg 800w
Чтобы вернуть только тот URL, который вы можете сделать: -e 'substring-before(max(tokenize(//@srcset,", "))," ")'
.