Help taking text from a variable without non-text such as colons and question marks

I could use a bit of help.
I want to search variable A and apply the text located there to variable B without the non-text characters ":" and/or "?"
For example, if variable 4991 contains the string "Avengers: Endgame?" I would like the text "Avengers Endgame" without the colon and question mark to be put into variable 198.
Can anyone help me with this in MZ?

Other punctuation is fine, its only question marks and colons that are a problem for me because they can not be used in filenames so they cause problems for me.

Thanks for your time!
Something like this?

$gameVariables.setValue(198, $gameVariables.value(4991).replace(":", ""));

EDIT

Just tested the below and it seems to work.

JavaScript:
$gameVariables.setValue(41,"Avengers: Mother");
$gameVariables.setValue(42, $gameVariables.value(41).replace(":", ""));

1708907895705.png
Thank you very much! I appreciate the help!
You can use this (regex) to remove any special characters from the string inside the variable:
JavaScript:
let v = $gameVariables._data;
v[4991] = "Avengers: Endgame?";
v[198] = v[4991].replace(/[^a-zA-Z ]/g, "");

Variable 198 would show "Avengers Endgame".
You can use this (regex) to remove any special characters from the string inside the variable:
JavaScript:
let v = $gameVariables._data;
v[4991] = "Avengers: Endgame";
v[198] = v[4991].replace(/[^a-zA-Z ]/g, "");

Variable 198 would show "Avengers Endgame".
Thank you very much. This saves me from running the script multiple times for each character I want to omit.
Greatly appreciate everyone helping out!
I think the thread is solved now. 😀
Also, just to mention it, presuming you're then using this filename in an MZ project, you shouldn't be allowing spaces, either.

Any characters that are non-URL-compliant should be avoided in MZ, since it can cause loading errors with a deployed game.

1708912147691.png
Also, just to mention it, presuming you're then using this filename in an MZ project, you shouldn't be allowing spaces, either.

Any characters that are non-URL-compliant should be avoided in MZ, since it can cause loading errors with a deployed game.

View attachment 296555
Thank you for letting me know.

Original thread: https://forums.rpgmakerweb.com/threads/help-taking-text-from-a-variable-without-non-text-such-as-colons-and-question-marks.166165/