Using automation to update a field with bad data

I have a table in which users paste in the URL into a URL field, but they often paste in the wrong URL ( is the right URL, and they paste in

I currently have a formula that replaces the cruft and puts it in a new field (SUBSTITUTE({Link},"#finished","")), but I’d rather use automation to update the field in place. Can someone help me with the script I need to run?