Re: [ljc] Lambda expressions for the regex classes

From: Martijn V.
Sent on: Friday, January 4, 2013 7:58 PM
This was fun to reason out with Ben the other day while we were  editing his article on Lambdas. even the simple use case of filtering based on a regex makes a an awful lot of sense.


On Friday, 4 January 2013, Ben Evans wrote:

Cross-post from Adopt-OpenJDK.

If there's anyone here who's interested in helping out with some
technical work with lambdas, please have a read of this post & come &
join us on the AdoptOpenJDK mailing list for discussion.



Hi all,

There's been a short thread on lambda-dev about adding new methods to
the Java regular expression classes (java.util.regex.*) to take
advantage of lambda expressions.

I've proposed adding this method to java.util.regex.Pattern:

public Predicate<String> asPredicate(){
    return s -> this.matcher(s).find();

This would then mean that given you could do things like this:

Pattern p = Pattern.compile("\d+-\d+");
List<String> myStrs = getSomeStrings();
List<String> phoneNumbers = ArrayList<>());

in order to filter a list of all the things which aren't phone numbers.

Brian was receptive to this idea, and wants to see what other "point
lambdaifications" we can come up with for the regular expressions

So, can you have a think about the existing java.util.regex classes &
see where any of the new lambda technology & classes could be added to
the existing support to make life easier?

If you post your ideas here, we can talk about them as a group, and
then when we've got a few good ideas, I can take them back to Brian.

What do you think - who's up for this?



Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Ben Evans ([address removed]) from LJC - London Java Community.
To learn more about Ben Evans, visit his/her member profile:
Set my mailing list to email me

As they are sent

In one daily email

Don't send me mailing list messages
Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference, in collaboration with the LJC 12/13 Jun 14

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • Packt Publishing

    A publishing company specializing on specific technologies and solutions

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy