Created
April 30, 2021 16:57
-
-
Save Ram-1234/08f929d99f63c344a5cafc16c3518ade to your computer and use it in GitHub Desktop.
remove a substring from given string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example-1 | |
input;- | |
I am a very good engineer | |
very | |
output:- | |
I am a good engineer | |
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Ideone | |
{ | |
public static void main (String[] args) throws java.lang.Exception | |
{ | |
Scanner sc=new Scanner(System.in); | |
String name=sc.nextLine(); | |
String key=sc.nextLine(); | |
//System.out.println(key); | |
String result=name.replace(key,""); | |
result=result.replaceAll(" +"," "); | |
System.out.println(result.trim()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment