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

General Discussion

RegEx practice/tutorial

Hi everyone, does treehouse have some more information on regular expressions? Just want to get more practice.

16 Answers

Have you watched Lea Verou's presentation on Regular Expressions and interacted with the slides?

Cody Lindley has a bunch of great resources about Regular Expressions as well.

Emil Martinov
Emil Martinov
2,935 Points

Lea Verou's presentation looks awesome, she describes and illustrates regex beautifully. Finally I am grasping it. Thank you.

Stone Preston
Stone Preston
42,016 Points

Rubular is a handy tool for practicing and testing regexes

James Barnett
James Barnett
39,199 Points

There's not currently any videos on regex on Treehouse. Seems like it would be a good topic for a Workshop.

In the meantime check out http://regexone.com/

After that you can check out either of these (paid) courses, if you want more info:

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hello Caleb King and World!

I've put a little video together for you covering some basic regular expressions. Here's the project files: here.

Why not extend this project by creating some validators using regular expressions. Here's some examples – zip and postal codes, First and Last names that have capitalized first letters, email addresses. Also share them and improve them with fellow students here on the forum. Maybe start a new topic per thing you're trying to validate so that the discussions can focus on a particular thing.

The website I use when I need to look up stuff is regular-expressions.info.

How this helps!
Andrew

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Great Tutorial Andrew, thanks for posting it. Great to see a British teacher on Treehouse. See you on the Javascript track. :)

Timothy Boland
Timothy Boland
18,237 Points

this one is awesome...are there any plans to include all of these Forum videos in the Library? It would make them easier to find and browse.

Steven Pribilinskiy
Steven Pribilinskiy
8,400 Points

Andrew, you could avoid switching between SublimeText and the Browser by simply adding two input fields, one for Patterns and another for Modifiers right onto the page.

Very nice tut, especially the password checker with combined positive lookaheads. There isn't really a way to perform three tests on a single input string just by using a single regular expression, just because we can't "move the caret" within the string with RegExp, but in this case the task is solved with the ?= token. At first I thought you would solve the problem with Javascript, also succinctly, I think: function isPasswordValid() { return [/[a-z]/, /[A-Z]/, /[0-9]/].every(function(r){ return r.test($password.val()) }) }

Well, it looks much nicer in coffeescript: isPasswordValid = -> [/[a-z]/, /[A-Z]/, /[0-9]/].every (r) -> r.test $password.val

Hi there!

I was just looking as some random posts and i camed across this one with an useful video .

I don think this video is in the library is it? I from look at students, they engioj it .

Though i was looking at random posts via google, i don't think people will actually see this useful video .

What do you think to put it in the library ? Since is here, and its hidden, I'm sure students will engioj it to see it and know about it.

Miriam Tocino
Miriam Tocino
14,201 Points

Hi Andrew,

Just following another course in which I was supposed to be familiar with regular expressions, google if there was sth about it at Treehouse and found your video.

Quick introduction, directly to the point! Thanks a lot :)

So helpful. Thx!

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Not going to be super-handy in every language, but I love pythex for testing regular expressions. It's designed for Python but since Python's regexs are mostly just POSIX regex, it'll work many other places.

I will also recommend http://www.regexr.com/ in addition to this resource and the ones from Lea Verou I posted earlier this week about.

Awesome thanks team!

Very insightful!

thanks :)

Martha Garvey
Martha Garvey
1,865 Points

Cool. Even more nifty content.

Very good introduction to regular expressions.

Thanks a lot. Regular Expressions looked really scary to me before, but now I can see how useful it is!

can we have regex course on JS ?

Ajinkya Borade: The Regular Expressions in Python course launched today, and I recommend taking it to get a hang of regular expressions despite hoping for a JS-centric course to be in the works regarding regular expressions.

RegEx concepts are very interchangeable between langauges. The methods, signatures, and instantiation steps associated with regular expressions from language-to-language, but the core ideas of working with regular expressions, solving problems with regular expressions, or creating regular expressions are essentially the same from language-to-language.

What you often have to consider is what RegEx features/concepts a particular language supports or doesn't support to avoid spending unnecessary time using a language that doesn't work well with the problems you believe RegEx is a good fit for.

For example, you will have quirks in JavaScript compared to traditional programming languages because the lack of support of negative lookbehinds and other advanced regex features (some of which are being added to JS based on the ES6 specification).

alright ;)

Thomas Pane
Thomas Pane
7,804 Points

can someone please tell me why i continue to get true returned in my console no matter if my username starts with a special character or symbol? .function userTest () { var usernameRegex = /^[a-zA-Z0-9]{3,16}$/ var username = $('username').val(); console.log(usernameRegex.test(username)); }