They are all based on the extension of String.prototype:
The reason is that a netizen discussed two functions with me.
One is isDateTime (to determine whether the character conforms to the yyyy-mm-dd hh:mm:ss date format)
The other is the left function, which is similar to vbscript's left to implement mixed interception of Chinese and English characters.
Both of his functions used loops and more than N if statements. Each function exceeds 40 lines of code. He asked me if there is a good way to streamline it.
So, I wrote the following code. I don’t dare to say it is the most efficient, but it is streamlined enough. The left function is only 1 line.