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 trialmohamedmousa
289 Pointswhat is the answer for practice number 1 ??
1 ) Match:
foxes jumping dogs
Exclude:
aaaaa
my answer :
[^a]+
[^a]{3,7}
but both answer not match
6 Answers
Steven Parker
231,248 PointsYour first answer ("[^a]+
") seems to work. If I put that into regexpal all the match words are highlighted in yellow, but the exclude word is not.
Does it do something else for you?
Robert Reed
2,529 Points[^a]+ is not a correct answer.
As you all have mentioned, this highlights everything in yellow, indicating it is a single match, rather than 3 separate matches as is intended.
Of the solutions proposed, Nathan's solution of [d-x]+[^a] works (although the [^a] is not needed), and Steven's solution of [dfj]\w+ also works.
I wonder what the instructor's "ideal" solution is.
Gabbie Metheny
33,778 PointsI used [^a\s]+, which excludes the letter 'a' as well as any white space (spaces or new line characters between words), and requires 1 or more characters for a match. I got three separate matches for foxes, jumping and dogs.
Steven Parker
231,248 PointsThat works as long as there's no punctuation. But unlike "[^a\W]+
", that will include any punctuation with the matched words.
Gabbie Metheny
33,778 PointsThat's a good point, Steven. The example Joel gave didn't contain any punctuation, so I think either would work equally well in this specific case.
Laércio Filho
883 PointsAs Steven said, the correct answer is: ("[^a]+"). Everything is highlighted except ("aaaaa").
Nathan Brenner
35,844 Points/[d-x]+[^a]/
is another solution for this case.
Steven Parker
231,248 Pointsif you constrain the first letter, you don't really need to exclude the a's:
/[dfj]\w+/
would work too.
Keith McGill
Full Stack JavaScript Techdegree Student 6,852 PointsThe instructions did not explicitly say we must use a negated character set([^]) so I did: [b-z]{4,7} and got 3 separate matches and excluded the aaaaa.
mohamedmousa
289 Pointsmohamedmousa
289 PointsThe same happens with me, all the match words are highlighted in yellow, but the excluded word is not.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsSo doesn't that mean the answer is correct? Or does it need to be constrained to words? ("[^a\W]+" gives 3 separate matches)