Help! Get id of tag <IMG>

Hi,
sorry for dummy question, but I’m a newbie.

I’ve a html page with contains lot of images with different id:
<.IMG src=“image_link” id=“image_number_1”>
<.IMG src=“image_link” id=“image_number_2”>
<.IMG src=“image_link” id=“image_number_3”>
<.IMG src=“image_link” id=“image_number_4”>

I would access the img tag and store the id in a variable (possibly only the substring “number_X”).

How can I do this?

Thank you very much

{
  "Name": "getID",
  "CreationDate": "2022-8-27",
  "Commands": [
    {
      "Command": "executeScript",
      "Target": "const img = document.querySelectorAll('img')\n\nconst data = []\n\nfor (const x of img){\n  const temp = x.id.split(/_(.*)/s)[1]\n  data.push(temp)\n}\n\nreturn data",
      "Value": "getID",
      "Description": ""
    },
    {
      "Command": "forEach",
      "Target": "getID",
      "Value": "ID",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${ID}",
      "Value": "green",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}

Hi, thank you for your reply. Probably I was not too clear in my request…
<.IMG src=“image_link1” id=“number_1”>
<.IMG src=“image_link2” id=“number_2”>
<.IMG src=“image_link3” id=“number_3”>
<.IMG src=“image_link4” id=“number_4”>

I need to access code with a specific SRC and I need to get the ID and store this information to be used in next step.

For example: I need to retrieve the ID of image with src=“image_link3”. Result should be a variable sotred with text numebr_3 (or possibly only number 3 as substring of id text)

Thank you and regards