-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11012023.java
More file actions
34 lines (28 loc) · 901 Bytes
/
Copy path11012023.java
File metadata and controls
34 lines (28 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.regex.Matcher;
import java.util.regex.Pattern;
interface StringFunction {
String run(String str);
}
public class Main {
public static void main (String[] args) {
StringFunction exclaim =(s) -> s + "!";
StringFunction ask =(s) -> s + "?";
printFormatted("Hello",exclaim);
printFormatted("Hello", ask);
reg();
}
public static void printFormatted(String str, StringFunction format) {
String result = format.run(str);
System.out.println(result);
}
public static void reg () {
Pattern pattern = Pattern.compile("schools", Pattern.CASE_INSENSITIVE);
Matcher mathcer = pattern.matcher("Visit schools");
boolean Found = mathcer.find();
if(Found){
System.out.println("Match found");
} else {
System.out.println("Not found");
}
}
}