✔ 最佳答案
/*
Here is the sample code. See if this is what you wanted.
Have a nice day!
*/
import java.io.*;
import java.util.regex.*;
class Chead
{
public static void main(String[] args)
{
String strHay = null;
Pattern pttnNeedle = null;
Matcher mtchrNeedle = null;
String strResult = null;
// generate a case-insensitive regexp pattern from the 1st param
if (args.length > 0)
{
pttnNeedle = Pattern.compile
(
args[0]
, Pattern.CASE_INSENSITIVE
);
}
// loop through other parameters and removes the matched strings
for(int i = 1; i < args.length; i ++)
{
strHay = args[i];
mtchrNeedle = pttnNeedle.matcher(strHay);
strResult = mtchrNeedle.replaceAll("");
System.out.println("The result is:\n\t" + strResult);
}
return;
}
}