Lambda expressions for the regex classes

From: Ben E.
Sent on: Friday, January 4, 2013 7:53 PM
Hi,

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.

Thanks,

Ben

----------
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.Patt­ern:

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 =
myStrs.stream().filt­er(p.asPredicate()).­into(new 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
classes.

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?

Cheers,

Ben

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."

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • 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