5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

文字列のreplace(正規表現)を複数行対応

Last updated at Posted at 2012-02-21
replaceLine.js
String.prototype.replaceLine = function (_regExp, _repText) {
	var tExp = String(_regExp);
	var regExp = new RegExp(tExp.split("/")[1], tExp.split("/")[2]);
	var strArry = this.split("\n");
	var strRet = "";
	
	for (var i in strArry) {
		strRet += strArry[i].replace(regExp, _repText) + "\n";
	}
	return strRet;
};
5
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?