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 trialZaid Khan
12,769 PointsHow to Match and Exclude for exercise 02
I am stuck in exercise 2. So far I am able to match but couldn't exclude numbers 4.
Here is what I was trying:
[\d\sab]
Test String:
1 a
2 a
3 a
4 a
5 a
8 a
9 b
4 c
4 E
Please any help would be appreciated.
Zaid Khan
12,769 PointsHello, Ashish Mehra
I tried your solution it's excluding perfectly but also not matching the 4 a
string now.
2 Answers
Zaid Khan
12,769 PointsI tried playing with Ashish Mehra RE and came up with
(?![4]\s[cE])\d+ \w
It matched and excluded as well.
Please share if someone came up with a different solution.
Ashish Mehra
2,411 PointsAwesome cheers,
Want to share https://regexr.com/ is a great tool which I forgot to mention earlier. It give description of each character in regex expression.
Zaid Khan
12,769 PointsThank you Ashish Mehra I will surely check this out, this seems very helpful.
gurgucristian
7,692 PointsVery late answer but
\d [ab]
works as well and is the simplest solution I can think of.
Ashish Mehra
2,411 PointsAshish Mehra
2,411 PointsHi Zaid Khan ,
I come up with this solution
(?![4])\d+ \w
You can test and play with regex (here)[https://regex101.com/]