Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript returns the number of categories that a string is composed of

Shulou Source: shulou.com Published: 2022-06-01 02:56:20 10月26日 Update

This article will explain in detail how JavaScript returns the number of types of string composition. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Returns the number of types of string components (letters, numbers, punctuation)

The origin of LIP abbreviation: l (letter letter) + I (uint number) + P (punctuation punctuation)

Description of parameter punctuation:

Punctuation refers to an acceptable set of punctuation

To customize the symbol set, such as "include only underscores and underscores", set the parameter to "- _".

If the value is not passed or the default is null, the internal default set of punctuation marks is English punctuation marks except spaces: ~ `! @ # $% ^ & * ()-_ + = [] {};: "', /?

Function getLIPTypes (str,punctuation=null) {

Let p_regexp = new RegExp ('['+ getPunctuation (punctuation) +']')

Return / [Amurz] / .test (str) + / [0-9] / .test (str) + p_regexp.test (str)

} the characteristic of JavaScript 1.JavaScript is mainly used to add interactive behavior to HTML pages. 2.JavaScript can be embedded directly into HTML pages, but writing as a separate js file facilitates the separation of structure and behavior. 3.JavaScript has cross-platform features and can run on multiple platforms with the support of most browsers.

This is the end of this article on "how JavaScript returns the number of types of string components". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Symbols punctuation punctuation characters strings quantities categories articles parameters letters numbers more behavior pages good practical underlined content multiple platform Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia Shulou Technology MySQL OPPO Reno