Created
June 13, 2016 14:59
-
-
Save SingingBush/fccd964259f282d85de3c0e8d74f84a8 to your computer and use it in GitHub Desktop.
Create a Java 8 Stream of Strings matching a regex on a given String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Stream<String> regexPatternMatchStream(final String pattern, final String target) { | |
final Matcher matcher = Pattern.compile(pattern).matcher(target); | |
final Stream.Builder<String> sb = Stream.builder(); | |
while (matcher.find()) { | |
sb.add(matcher.group()); | |
} | |
return sb.build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment