When you type set /?, the portion of help that relates to environment variable substitution contains:


would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2".  "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output.  "str1" can begin with an asterisk, in which case it will match
everything from the beginning of the expanded output to the first
occurrence of the remaining portion of str1.
If str1 contained an unknown number of unknown characters preceding a known string, you can use the * character to remove them.


If the string variable contained:
String            command                           Resulting String
1234ABCD          set string=%string:*ABCD=ABCD%    ABCD
12345678ABCD      set string=%string:*ABCD=ABCD%    ABCD
A1B2C3D4E5ABCD    set string=%string:*ABCD=ABCD%    ABCD