Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Regular Expressions in Java

Evgeniia Vakarina
Evgeniia Vakarina
3,317 Points

Will "next door to Dylan in 90210" really match?

I tried it in workspace and it didn't. I got curious and tried this: String shorter = "1234"; String same = "12345"; String longer = "123456"; String withWords = "some words 12345"; System.out.println("Shorter number: " + shorter.matches("\d{5}")); System.out.println("Same length number: " + same.matches("\d{5}")); System.out.println("Longer number: " + longer.matches("\d{5}")); System.out.println("With words: " + withWords.matches("\d{5}"));

All except the same length number were false. So do we really need to add "^" and "$"?