---
title: "java实现不区分大小写替换"
author: "fanjf"
date: "2008-11-17T15:19:00Z"
tags: []
categories: ["开源软件"]
slug: "java"
draft: false
lastmod: "2012-02-22T12:09:20Z"
id: 299862
url: "https://fanjf.iteye.com/blog/299862"
---

/\**  
  * java实现不区分大小写替换  
  * @param source  
  * @param oldstring  
  * @param newstring  
  * @return  
  \*/  
public static String IgnoreCaseReplace(String source, String oldstring,  
   String newstring){  
      Pattern p = Pattern.compile(oldstring, Pattern.CASE\_INSENSITIVE);  
      Matcher m = p.matcher(source);  
      String ret=m.replaceAll(newstring);  
      return ret;  
}  
以上是利用正则表达式实现不区分大小写替换。