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

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

WBOY
WBOYOriginal
2016-05-16 16:52:521415browse

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');
}
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