package java2;
public class met {
public static String output1;
public static void fn(String ip1)
{
if (ip1.matches(".* is
.*")) {
output1 = ip1.replace(" is
", " is not ");
}
}
public static void main(String[]
args) {
fn("This is
a misconception.this ");
System.out.println(output1);
}
}
Another
method:
private
static
void
fn(String st) {
String o="";
String[] str=st.split(" ");
for(int i=0;i<str.length;i++){
if(str[i].equals("is")){
str[i]="is not";
}
}
for(int i=0;i<str.length;i++){
o=o+"
"+str[i];
}
op=o.trim();
}