JSFiddle - React, Tailwind, and code Playground
HTML
<span>https:// www.example.com/A/1234567/B/D?index.html</span>
<span>http://www.example.com/A?index.html/pd=123456789</span>
<span>http://www.e9999999999xamp9879897978le.com/A/B/C/1234567?index.html</span>
JavaScript
$("span").each(function() {
console.log($(this).text().match(/\d+/)[0]);
});