This is a problem that has never been noticed. The point is that replace in C # is a global replacement character (string), while in Javascript, it is only replaced with the first matched character.Code, JavaScript is as follows:
VaRSource='Abc123abc456abc';
VaRDesc=Source. Replace ('ABC','');
Alert (DESC );
The result is 123abc456abc.
The code in C # is as follows:
String source = "abc123abc456abc"; string DESC = source. Replace ("ABC", ""); console. Write (DESC );
Result: 123456
The corresponding JavaScript function should be written as follows:
VaRSource='Abc123abc456abc';
VaRDesc=Source. Replace (/ABC/G,'');
In this case, the implementation of C # is hard to understand. So we decompiled the string.
It seems that this should introduce the. NET kernel function. Then use msil to decompile mscorlib. dll and find the replace implementation:
We can see that it is internally called the pencil class library. Of course, this class library has been encapsulated internally and we cannot know the implementation.
Here we leave a todo.