Home > Web Front-end > JS Tutorial > Several efficient and concise character processing functions_javascript skills

Several efficient and concise character processing functions_javascript skills

WBOY
Release: 2016-05-16 19:15:07
Original
1028 people have browsed it

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.

Copy code The code is as follows:

1

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template