We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b5824e commit 62b904eCopy full SHA for 62b904e
java8Tutorials/src/main/java/java8/stream/StreamDemo5.java
@@ -0,0 +1,31 @@
1
+package java8.stream;
2
+
3
+import java.util.regex.Matcher;
4
+import java.util.regex.Pattern;
5
+import java.util.stream.Stream;
6
7
+/**
8
+ *
9
+ * @author saurav
10
11
+ */
12
+public class StreamDemo5
13
+{
14
+ public static void main(String[] args)
15
+ {
16
17
+ Stream.of("a1", "aa", "a3")
18
+ .map(a->findInt(a))
19
+ .forEach(System.out::println);
20
+ }
21
22
+ private static Integer findInt(String s)
23
24
+ Matcher m=Pattern.compile("[0-9]+").matcher(s);
25
+ if(m.find())
26
27
+ return Integer.parseInt(m.group());
28
29
+ return null;
30
31
+}
0 commit comments