Using XPATH for dynamic objects

I am trying to locate an object that has a dynamic unpredictable id that gets used in the ID affecting all selector options. Also there are more than one of these items on the page so using any selector that doesn’t use the specific ID would capture all of them. I need to be able to find this specific item which is the last one of these items.

The xpath for the objects looks like


where xxx is the unpredictable numeric ID that is created for this object.

(My Regex attempt)


I have tried everything from regex to starts with. I have been through multiple forum posts trying to find a way to do this. I am not sure if variables would be an option since I have no real way to know what the ID will be.

You can use the xpath (//*[contains(@id,“item”)]/div[1]/div[1]/div[1]/i)[last()]
This will get the last object matching this xpath

While doing the recording if I use that as the xpath then click verify and highlight it works but when I run the test it does not.
“located by ‘By.xpath: (//*[contains(@id,“item”)]/div[1]/div[1]/div[1]/i)[last()]’ not found)”

This has been fixed Using the suggested xpath above. Apparently there was an issue with the quotes. Thanks Dan