Interesting challenge. The following should do it. I don't use Trino myself so is not tested.
SELECT _.ID FROM ( SELECT ID, reverse(split(URL, "/")) as Elements ) AS _ WHERE cardinality(_.Elements) >= 2 && _.Elements[0] = _.Elements[1]