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

JavaScript Regular Expressions in JavaScript Regular Expressions Using Wildcard Characters

huckleberry
huckleberry
14,636 Points

Am I missing something here with the exclude??

What's with the exclude tasks here. Are these teacher's notes for another section? lol

He didn't cover 'excluding' characters in any sort of regEx notation in this video and some examples don't even make sense as to why you'd exclude.

Take the first example.

7849
3472
8901
70502 
23470 
90496

then 'exclude' abcde and ABCDE

Ok um, why? There are no alpha characters whatsoever in that string set. (edit: Ok, I re-read the instructions and he says to paste BOTH sets of text into regexpal and then exclude. See updated example) Plus, considering we haven't learned any sort of multiplier yet, the answer would seem to be

\d\d\d\d\d? ?

Updated Example

7849
3472
8901
70502 
23470 
90496
abcde 
ABCDE

Edit: Ok, my 'answer' still stands, no?

The first two 5 numeric strings have a space at the end of them in the teacher's notes section hence the ? notation there at the end.

So, what am I missing out on here? What isn't sinking in? Is it simply 'exclude these strings by way of omission within the pattern' or is there an actual exclude notation that just wasn't covered here?

Trying to go off of only what was learned here (or else that first one could just be \d* if my googling is correct.

And the second one would be [\d] [ab] yes? For

1 a
2 a
3 a
4 a
5 a
8 a
9 b
4 c //exclude
4 E //exclude

Cheers,

Huck - :sunglasses:

1 Answer

Steven Parker
Steven Parker
231,269 Points

Your solution for the digits is good. Another one would use a character class that includes both a digit and a space, like this: "\d\d\d\d[\d ]?".

That "multiplier" you were wanting will be covered in the next video on repeated characters.