Quantcast
Channel: Obtain Regex matching Groups using Pattern.asPredicate() - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by Alexander Ivanchenko for Obtain Regex matching Groups using...

Firstly, there are several issues that worth to emphasize:In you've code started with a filter() operation and that was the right step, because map() can't discard an element from the stream, it...

View Article



Answer by user17233545 for Obtain Regex matching Groups using...

You should .map() instead of .filter().ArrayList<String> mylist = new ArrayList<>( dest.stream() .map(s -> s.replaceAll("\\D+\\s\\D+\\s(\\d+\\.?\\d+)", "$1"))...

View Article

Answer by f1sh for Obtain Regex matching Groups using Pattern.asPredicate()

filter keeps or removes elements from the list. If you want to transform stream elements (which you do when you extract the number), use map.Then you can use the regex (along with a Matcher) to extract...

View Article

Answer by Youcef LAIDANI for Obtain Regex matching Groups using...

I'm trying to get the number at the end of every string...Solution 1Maybe you can solve it without using regex, like so:List<String> response = dest.stream() .map(String::trim) .map(s ->...

View Article

Obtain Regex matching Groups using Pattern.asPredicate()

Suppose that I have a list:List<String> dest = Arrays.asList("abc abd 2000","idf owe 1200","jks ldg 789","ccc hhh 2000","www uuu 1000");And I'm trying to get the number at the end of every...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images