I agree with WebElaine’s comment, that storing IDs would be far more reliable, since URLs can so easily change.
That said, if you have a URL like so:
http://domain.com/2018/01/this-is-my-post/
You can use something like this to obtain the post name:
$url="http://domain.com/2018/05/this-is-my-post/";
$components = parse_url($url);
preg_match('`^/\d*/\d*/(.*)/$`', $components['path'], $matches);
echo $matches[1];
Using the post name in $matches[1]
you can use get_page_by_path
to obtain the post object.
$post = get_page_by_path($matches[1]);
From there you can retrieve any value with its ID using $post->ID
.