I use the Google Drive API, and the refresh_tokenone I get has a hidden slash. Although this must be a valid JSON, the API will not accept it when called refreshToken(). I am trying to remove the backslash with preg_replace:
$access_token = "1\/MgotwOvbwZN9MVxH5PrLR2cpvX1EJl8omgYdA9rrjx8";
$access_token = preg_replace('/\\\//', '/', $access_token);
I would like the returned string to be:
"1/MgotwOvbwZN9MVxH5PrLR2cpvX1EJl8omgYdA9rrjx8";
I tried various expressions, but it either does not remove the backslash or returns an empty string. Note that I do not want to remove all backslashes, only those that escape the slash.
source
share