Find and Replace within an existing script

We have an existing script on our Routerboards containing an endpoint we would like to replace.

In the example below I would like to replace end.point.com with a new endpoint. Is this possible or is it best to remove the script entirely and add it in again with the new endpoint?

:local currentVPNServer [/interface ovpn-client get vpn-interface connect-to]
:local newVPNServer [/resolve end.point,com;
:if ([:len [:toip $newVPNServer]] > 0) do={
:if ( != ) do={
/interface ovpn-client set connect-to=$newVPNServer vpn-interface;
:log info “IP updated”;
}
}

Thanks, Matt

You can update the current script using:

/system script set [find  name=scriptname] source=":local currentVPNServer [/interface ovpn-client get vpn-interface connect-to];:local newVPNServer [/resolve newend.point,com;:if ([:len [:toip \$newVPNServer]] > 0) do={:if ( != ) do={/interface ovpn-client set connect-to=\$newVPNServer vpn-interface;:log info \"IP updated\";}}"

Thanks for this. Will test it out.