0

White space remains where symbols use to be..Any Solutions??

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); String x = input.nextLine(); String y = x.replaceAll("[^a-zA-Z0-9]"," "); System.out.println(y); } }

21st Apr 2020, 1:59 PM
Fardeen A
Fardeen A - avatar
1 Answer
0
You're replacing space with symbols so remains. If don't want replace nothing.. If you want space from original, include a space in regex.. String y = x.replaceAll("[^a-zA-Z0-9 ]","");
21st Apr 2020, 2:18 PM
Jayakrishna 🇼🇳