forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
22 lines (14 loc) · 757 Bytes
/
Main.java
File metadata and controls
22 lines (14 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package modern.challenge;
public class Main {
public static void main(String[] args) {
String text = "This is a text from 20 April 2050";
String noNrClassic = Remover.remove(text, new NumberRemover());
System.out.println("No numbers result (classic): " + noNrClassic);
String noWsClassic = Remover.remove(text, new WhitespacesRemover());
System.out.println("No whitespaces result (classic): " + noWsClassic);
String noNr = Remover.remove(text, s -> s.replaceAll("\\d", ""));
System.out.println("\nNo numbers result (lambda): " + noNr);
String noWs = Remover.remove(text, s -> s.replaceAll("\\s", ""));
System.out.println("No whitespaces result (lambda): " + noWs);
}
}