---
title: "关于IE下不支持js的trim()方法的解决方案"
author: "cline"
date: "2012-08-13T10:52:36Z"
tags: []
categories: ["编程语言"]
slug: "ie-js-trim"
draft: false
lastmod: "2012-08-13T10:52:36Z"
id: 1630089
url: "https://hussion.iteye.com/blog/1630089"
---

```javascript

  str = str.replace(/^\s+|\s+$/g,'');

```


原理是利用正则表达式进行替换操作。。。