hi ,evertbody

I am very new to Java. I plan to search a string in my HTML file in Regular Expression.In my file, it exists the string I want to find. But it does not give me the right result. maybe the pattern is not right.

Who can tell me how to create a Pattern to find the string "Welcome".

Thanks a lot!

The following is my code:

import java.io.*;
import java.util.*;
import java.util.regex.*;

public class TitleMatch
{
FileReader fis;
String username;

TitleMatch(FileReader fis,String username)
{
this.fis=fis;
this.username=username;

}


public void findString()
{
// open reader for file
try


{
//InputStreamReader in = new InputStreamReader(fis);

// read contents into string buffer
String input ;
String patternString = ".*Welcome.*";
Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE+Pattern.UNICODE_CASE);

BufferedReader in = new BufferedReader(fis);


while ((input=in.readLine())!=null)
{
if (input.equals("")) return;

Matcher matcher = pattern.matcher(input);

System.out.println(matcher.matches());

if (matcher.matches())
{

int start = matcher.start();
int end = matcher.end();
String match = input.substring(start, end);
input = matcher.replaceAll(match + " "+ username);
//int leng=input.length();
//input=input.subString(1,end)+ username+input.subString(1,end)+
//input.subString((end++),leng);

}
System.out.println(input);

}
}

catch (IOException e)
{
e.printStackTrace();
}
catch (PatternSyntaxException e)
{
e.printStackTrace();
}
}

public static void main(String[] args)
{
try
{
FileReader fis=new FileReader("welcome.html");
TitleMatch tm =new TitleMatch(fis,"judy");
tm.findString();
}
catch(FileNotFoundException e)
{

}

}

}