+ 2

[SOLVED]Can any one explain it for me??

what does that white space after 9 do?and how it does that? this is with white space: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine(); input = input.replaceAll("[^a-zA-Z0-9 ]", ""); System.out.println(input); sc.close(); } } and this without that white space: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine(); input = input.replaceAll("[^a-zA-Z0-9]", ""); System.out.println(input); sc.close(); } }

13th Jun 2020, 2:14 PM
hamid
hamid - avatar
2 Respostas
+ 2
"[^a-zA-Z0-9 ]" this regex string mean (replace) everything [^] but not a-zA-Z alphabet characters 0-9 numbers [^ ] and not space character String input = "aa-x x-BB-x x-99"; input = input.replaceAll("[^a-zA-Z0-9 ]", "."); System.out.println(input);
13th Jun 2020, 4:17 PM
zemiak
+ 1
thank you so much 👍
13th Jun 2020, 5:54 PM
hamid
hamid - avatar