Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction of Chinese examples of JavaScript regular expression validation

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "JavaScript regular expression verification Chinese example introduction", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "JavaScript regular expression verification Chinese example introduction" bar!

JavaScript often validates Chinese. Here are two examples:

Javascript Code:

The copy code is as follows:

/ * *

* A simple example

, /

Function ischinese (temp) {

Var re = / [^ u4e00-u9fa5] /

If (re.test (temp)) return false

Return true

}

/ * *

* verify whether the string is in Chinese

* return value:

* if it is empty, the definition is passed and true is returned.

* if the string is in Chinese, the verification passes and true is returned.

* if the string is not in Chinese, return the false reference prompt: must be in Chinese!

, /

Function ischinese2 (str) {

/ / if the value is empty, it passes the check

If (str = "") return true

Var pattern = / ^ ([u4e00-u9fa5] | [ufe30-uffa0]) * $/ gi

If (pattern.test (str)) return true

Return false

}

Thank you for your reading, the above is the content of "JavaScript regular expression verification Chinese example introduction", after the study of this article, I believe you have a deeper understanding of the problem of JavaScript regular expression verification Chinese example introduction, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report