Home > Web Front-end > JS Tutorial > JavaScript regular matching Chinese characters, numbers, letters, and underscores_Basic knowledge

JavaScript regular matching Chinese characters, numbers, letters, and underscores_Basic knowledge

WBOY
Release: 2016-05-16 16:52:52
Original
1437 people have browsed it

Javascript regular detection only contains Chinese characters, numbers, letters, and underscores and cannot start and end with underscores

I encountered a problem with username detection and checked it out. The summary example is as follows:

Copy code The code is as follows:

var reg = /^(?!_)(? !.*?_$)[a-zA-Z0-9_u4e00-u9fa5] $/;
if (!reg.test (actual value string)) {
alert('Please enter 5- 24-bit characters: supports Chinese, English, numbers, "_", Chinese is recommended');
}
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