In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how es6 removes all the spaces in the string". In the daily operation, I believe many people have doubts about how to remove all the spaces in the string by es6. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to remove all spaces in the string by es6". Next, please follow the editor to study!
In es6, you can use the replace () method to remove all spaces in a string, just use the replace () method with the regular expression "/\ sUnig" to find all spaces in the string and replace them with empty characters; remove the syntax to "string object .replace (/\ sUnig,")".
The operating environment of this tutorial: windows7 system, ECMAScript version 6, Dell G3 computer.
In es6, you can use the replace () method to remove all spaces from a string.
The replace () method is used to replace some characters in a string with other characters, or to replace a substring that matches a regular expression.
StringObject.replace (regexp/substr,replacement) parameter describes regexp/substr
Necessary. A RegExp object that specifies the substring or the schema to replace.
Note that if the value is a string, it is treated as an immediate amount of text pattern to retrieve, rather than being first converted to a RegExp object.
Replacement is required. A string value. Specifies the function that replaces the text or generates the alternate text.
Return value
A new string is obtained after replacing the first match or all matches of regexp with replacement.
Remove the method: use the replace () method with regular expressions to find all spaces and replace them with empty characters.
Regular expression used:
/\ sUnig
Implementation example:
Var str = "hello world" console.log ("original string:" + str+ "!"); var newStr=str.replace (/\ newStr+, "); console.log (" new string: "+ newStr+"! ")
At this point, the study of "how to remove all spaces in a string by es6" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.