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!
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
Pavlo Kochubei
15,009 Points\b@[-\w\d.] boundary question
In the Negation video, when filtering just email addresses we used the following line to set the first boundary.
'\b@[-\w\d.] '
But isn't '\b' supposed to return only the characters that have empty space before them, as it would return something like ' @treehouse.com", and \B supposed to return the characters with no whitespace before them?

Pavlo Kochubei
15,009 PointsYes, it's regex. Thanks for the website. I still have troubles understanding \b expression. It says that it supposed to 'assert position at the word boundary', which I'm having troubles understanding. Isn't it supposed to mean that everything that has whitespace before gets returned?
1 Answer

Unsubscribed User
3,273 PointsWell word boundary can mean any of three things:
- Before the first character in a string, when the first character is a word
- After the last character in a string, when the last character is a word
- Between two characters in a string, when part is a word and part isn't
In the case of the larger expression it looks like your are finding the @ symbol followed by a single character "-", A-Z (not case sensitive), or 0-9.
If we test that regex with the string "foobar@gmail.com" then "@g" will be your only match. This leads me to believe that the \b is saying that the word boundary (the start of the word) is the @.
On a side note if you're trying to capture email addresses I would use the following regex: (\w+@\w+.\w+)

Pavlo Kochubei
15,009 PointsThanks for the explanation. I guess it will come with practice.

Unsubscribed User
3,273 PointsRegex is confusing for everyone. I have a friend who is a CS professor/researcher and even he needs to refer to cheat sheets regularly when working with regex. It is fast, and useful, but in no way user friendly.

Pavlo Kochubei
15,009 PointsHa, interesting:) I won't be so hard on myself. Thanks again!
Unsubscribed User
3,273 PointsUnsubscribed User
3,273 PointsIs that a regex search your asking about?
In the case that it is regex that you are asking about I would enter it in at regex101, the explanation that pops up on the right will tell you what will result from your search.