Extract ID from IRI without using a regex? [closed]

  api-platform.com, iri, symfony

Im setting a condition in a voter which needs to make some validation based on a parameter in the request body, in this scenario the book Id.

The request body

    "name": "The name",
    "book": "/api/v1/books/e9ea1820-1957-427c-8ab7-17fb7a907f29"

I have worked on getting the request body inside the voter and now I’m getting the whole IRI. But now I need to, in some way, extract the Id from the IRI. The first solution I think is to have a regex, but I want to know if there is a way to do this without using regular expressions.

Source: Symfony Questions