the requirement is to remove the fixed format string from a js string, such as
result = "123456789"
the requirement is to remove the fixed format string from a js string, such as
result = "123456789"
let str="123&1456&a789&.";
let result = str.replace(/&./g,"");
regular is: / &. / g
let result = str.replace (/ &. / g, "");
I don't know the last one is & you don't need to remove
such as
let str = '12341231&';
is it necessary to replace & in this case?
if necessary, the regular should be
/(&.)|(&$)/g
No, it should be the one upstairs
/&./g
doesn't feel right. There is a a
in the original string. Do not see the corresponding processing in the regular expression?! Is it an input error that does not exist in the string itself?
if not, the simplest is reg=/&./g;
Previous: Webpack reported an error