1Customer james = customers.stream()
2 .filter(customer -> "James".equals(customer.getName()))
3 .findAny()
4 .orElse(null);
1import java.util.regex.*;
2
3public class GFG {
4 public static void main(String[] args)
5 {
6
7 // Get the regex to be checked
8 String regex = "Geeks";
9
10 // Create a pattern from regex
11 Pattern pattern = Pattern.compile(regex);
12
13 // Get the String to be matched
14 String stringToBeMatched = "GeeksForGeeks";
15
16 // Create a matcher for the input String
17 Matcher matcher = pattern.matcher(stringToBeMatched);
18
19 // Get the subsequence
20 // using find() method
21 System.out.println(matcher.find());
22 }
23}