-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegex5.java
More file actions
24 lines (20 loc) · 713 Bytes
/
Regex5.java
File metadata and controls
24 lines (20 loc) · 713 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package devsought;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Regex5 {
public static void main(String... args) {
String str = "The chef is in the kitchen preparing a meal.aacblkja";
Pattern pattern = Pattern.compile("^th", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(str);
if (matcher.find()) {
System.out.println("Matched::" + matcher.group());
} else {
System.out.println("NO MATCH");
}
}
}