Home > Web Front-end > JS Tutorial > body text

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

php中世界最好的语言
Release: 2018-03-12 11:46:29
Original
2504 people have browsed it

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));
Copy after login

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!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!