---
title: "html中回车，空格替换"
author: "cserw3c"
date: "2014-12-11T14:35:15Z"
tags: []
categories: ["Web前端"]
slug: "html"
draft: false
lastmod: "2014-12-11T14:36:26Z"
id: 2165165
url: "https://solomon2012.iteye.com/blog/2165165"
---

```
var str = "";
str = $('#ads').val(); 
str = str.replace(/[\n\r]/gi, "回车");  
str = str.replace(/[ ]/g, "空格");  
alert(str);
```

```
 
```