In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What are the methods of JavaScrip String object? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Method 1 of String object: indexOf () (recommended) var str = "123"; console.log (str.indexOf (" 3 ")! =-1); / / true
The indexOf () method returns the position where a specified string value first appears in the string. If the string value to be retrieved does not appear, the method returns-1.
Method 2: search () var str = "123"; console.log (str.search (" 3 ")! =-1); / / true
The search () method is used to retrieve a substring specified in a string or to retrieve a substring that matches a regular expression. If no matching substring is found,-1 is returned.
Method 3: match () var str = "123"; var reg = RegExp (/ 3 /); if (str.match (reg)) {/ / include}
The match () method retrieves the specified value within a string or finds a match of one or more regular expressions.
RegExp object method 4: test () var str = "123"; var reg = RegExp (/ 3 /); console.log (reg.test (str)); / / true
The test () method is used to retrieve the value specified in the string. Returns true or false.
Method 5: exec () var str = "123"; var reg = RegExp (/ 3 /); if (reg.exec (str)) {/ / include}
The exec () method is used to retrieve the match of a regular expression in a string. Returns an array containing the matching results. If no match is found, the return value is null.
This is the answer to the question about the method of JavaScrip String object. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.