You can write regex expressions that could do this.
Then you could use filters.
Suggest that you look into the PHP regex functions.
Regex is good.
It depends on what the data looks like at your source, and what tool you plan to use for the action.
In PHP you could use str_replace()
https://www.php.net/manual/en/function.str-replace.php
If I’m assuming correctly, you are looking at your URLs?
You could download your post id, and URL, and put all the URLs in an array.
Loop through each element and kick off a str_replace() that finds in your string, and replaces it with nothing.
There is also preg_replace :
https://www.php.net/manual/en/function.preg-replace.php