Home  >  Article  >  Web Front-end  >  js random string regular method ([A~Z],[a~z],[0~9])

js random string regular method ([A~Z],[a~z],[0~9])

php中世界最好的语言
php中世界最好的语言Original
2018-03-12 11:46:292471browse

This time I will bring you the random string of jsregular method ([A~Z],[a~z],[0~9]), the random string regular method of js ( [A~Z],[a~z],[0~9])NotesWhat are the following? Let’s take a look at the actual cases.

function ranNum(l) {    return Math.floor(Math.random() * (l[1] - l[0])) + l[0];
}function r(len) {    var s = "",t;    for (; len > 0; len--) {
        t = ranNum([[65, 91], [97, 123],[0, 10] ][ranNum([0, 3])]);
        s = s + (t > 10 ? String.fromCharCode(t) : t.toString());
    }    return s;
}console.log("测试",r(10));

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website

Other related articles!

Related reading:

nodejs How to use http module to write upload image interface test client

h5 production performance change polyline Figure

Detailed explanation of front-end and back-end development separation of Golang+Nodejs

How to make image upload preview component in H5

The above is the detailed content of js random string regular method ([A~Z],[a~z],[0~9]). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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