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

Python Regular Expressions in Python Introduction to Regular Expressions Negation

peter keves
peter keves
6,854 Points

verbose/multiline string / /b world boundery

1) verbose 2) multiline string 3) \b world boundery

can someome expain to me those terms ?

2 Answers

Verbose as it applies to python regular expressions means that both white space and comments are ignored. This makes it much more readable. Without the verbose flag it would be compacted together with no white space and no comments making it much more difficult to read. In python in general we are encouraged to white verbose code so that readability is at it's maximum.

multi-line string begins and ends with triple quotes (i.e. `'''). This allows us to write a string that takes up as many lines as we need. You can see Kenneth Love using this with the verbose flag so that he can break up a regular expression into smaller chunks.

A word boundary means either the beginning or end of a word. This can be based off of white space, the beginning of a new line or the end of a line. So \bfoo will match foobar and foo bar and bar foo, but not barfoo. Similarly foo\b will match foo bar and bar foo and barfoo, but not foobar.

Hope this makes sense.

peter keves
peter keves
6,854 Points

thanks for quick reply ! :) it helped me a lot

peter keves
peter keves
6,854 Points

so the verbose flag basicaly changes let's us change the style of a text but not the functionality ? is that correct ?

Yes - the verbose flag allows us to add white space (which is usually not ignored in regex) and comments without altering how the regular expression functions. Generally regular expressions look awful and are difficult to read and interpret. The verbose flag allows us to break this apart and add comments so that other's (or ourselves down the road) will be able to understand what is going on.