Thanks All for helping, but I am not getting the results. My file is changing to blank after trying to replace this code.
Type of String to replace in htm file : codebase="formbuilderocx.cab#version=3,7,0,6" viewastext id="formbuilderocx" Version string Needs to be replaced with a calculated string from other code (be it str_version =2,1,3,1 for sake) , so it should replace it to codebase="formbuilderocx.cab#version=2,1,3,1" viewastext id="formbuilderocx" What I am tryin out is this : while((str2 = in2.readLine()) != null){ System.out.println("result1"); if(str2.indexOf(htmFile[i]) != -1){ CharSequence inputStr = str2 ; //"ab12 cd efg34"; String patternStr = "[0-9]+(,[0-9]){3}"; //"([0-9],){4}+"; //"([a-zA-Z]+[0-9]+)"; // Compile regular expression Pattern pattern = Pattern.compile(patternStr); Matcher matcher = pattern.matcher(inputStr); System.out.println("result2"); // Replace all occurrences of pattern in input StringBuffer buf = new StringBuffer(); boolean found = false; while ((found = matcher.find())) { // Get the match result String replaceStr = matcher.group(); System.out.println(replaceStr); // Convert to uppercase replaceStr = str; System.out.println(replaceStr); // Insert replacement matcher.appendReplacement(buf, replaceStr); } matcher.appendTail(buf); // Get result String result = buf.toString(); System.out.println("result" + result); // AB12 cd EFG34 } And the result I am getting is that my htm file is overwritten and it becomes completely blank. Am I doing it wrong in here? -----Original Message----- From: Erskine, Chris [mailto:[EMAIL PROTECTED] Sent: Friday, March 04, 2005 11:53 AM To: Ant Users List Subject: RE: regular expression Note that that would fail due to not having a comma after the last digit. Chris Erskine EDS Consulting Services Colorado Springs, CO Phone: 719-265-5962 Cell: 719-640-6488 > -----Original Message----- > From: Mark Lundquist [mailto:[EMAIL PROTECTED] > Sent: Friday, March 04, 2005 9:46 AM > To: Ant Users List > Subject: Re: regular expression > > > On Mar 4, 2005, at 8:38 AM, Radha Sangal wrote: > > > Could someone help me build regular expression for a string like this > > 1,6,3,2. > > > > > > > > I am getting error if I write it like this String patternStr = > > "([0-9]+","+[0-9]+","+[0-9]+","+[0-9] + )" > > well yeah :-)... the above is not a valid string literal. Look at all > those double-quotes! > > Try this: > > String patternStr = "([0-9],){4}+"; > > See > http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html to > learn how to write regexps. > > GL, > -ml- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]