How to remove enter from javascript
This article mainly explains "javascript how to remove carriage return", the explanation content in the article is simple and clear, easy to learn and understand, please follow the idea of small series slowly in-depth, together to study and learn "javascript how to remove carriage return" bar!
javascript to remove the carriage method: 1, create an HTML file; 2, add script tags; 3, create a str variable; 4, by "str. replace (/[\r\n]/g,"");"remove the carriage.
Operating environment of this article: Windows 7 system, Javascript version 1.8.5, Dell G3 computer.
How to remove carriage returns from javascript?
js remove spaces from string carriage return
For example, the following json string
The middle\n means newline
var str ="{'retmsg ':' success',\n 'trans_date':'20170906 '}"; console. log (str);//"{' retmsg':'success',//'trans_date':'20170906 '}"//remove spaces str = str. replace (/\+/g,""); console. log (str);//"{'retmsg ':' success',//' trans_date ':' 20170906 '}"//remove carriage return str = str. replace (/[\r\n]/g,""); console. log (str);//"{' retmsg':'success',' trans_date':'20170906 '}"Thank you for reading, the above is the" javascript how to remove carriage returns "content, after learning this article, I believe we have a deeper understanding of how to remove carriage returns javascript this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!