Originariamente inviato da nikynik
finalmente le cose mi sono chiare....!
Prova questo:
codice:
import java.io.*;
import java.util.regex.*;
public class Prova
{
public static void main (String[] args)
{
try
{
String content = "Returns the offset after the last character matched.";
String regex = "the";
Pattern pattern = Pattern.compile (regex, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher (content);
int from = 0;
while (matcher.find ())
{
System.out.print (content.substring (from, matcher.start()));
System.out.print ("AAA");
from = matcher.end ();
}
System.out.print (content.substring (from));
System.out.println ("");
}
catch (Exception e)
{
System.out.println (e);
}
}
}