-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegEx.java
More file actions
36 lines (29 loc) · 978 Bytes
/
RegEx.java
File metadata and controls
36 lines (29 loc) · 978 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
33
34
35
36
/*
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegEx {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("Catan", Pattern.LITERAL);
Matcher matcher = pattern.matcher("Gwapa si Diether Catan!");
boolean matchFound = matcher.find();
if(matchFound)
System.out.println("Match found");
else
System.out.println("Match not found");
}
} */
import java.util.regex.*;
import java.util.Scanner;
public class RegEx {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("porn|scandal|fuck|sex", Pattern.CASE_INSENSITIVE);
Scanner input = new Scanner(System.in);
System.out.print("Search: ");
Matcher matcher = pattern.matcher(input.nextLine());
boolean matchFind = matcher.find();
if (matchFind)
System.out.println("Manyak ka!!!");
else
System.out.println("Searching...");
}
}