Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove enter from javascript

Shulou Source: shulou.com Published: 2022-06-02 16:46:38 10月02日 Update

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!

Tags: Learning content spaces variables characters strings that is ideas situations files articles methods more tags environment computers knowledge knowledge points articles systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux macOS Microsoft Shulou Information Apple