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 trialCaleb King
32,777 PointsRegEx practice/tutorial
Hi everyone, does treehouse have some more information on regular expressions? Just want to get more practice.
16 Answers
Kevin Lozandier
Courses Plus Student 53,747 PointsHave 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.
Stone Preston
42,016 PointsRubular is a handy tool for practicing and testing regexes
James Barnett
39,199 PointsThere'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
Treehouse Guest TeacherHello 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
Treehouse Moderator 91,253 PointsGreat Tutorial Andrew, thanks for posting it. Great to see a British teacher on Treehouse. See you on the Javascript track. :)
Timothy Boland
18,237 Pointsthis 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
8,400 PointsAndrew, 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
Aurelian Spodarec
7,369 PointsHi 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.
Bahi Hussien
Courses Plus Student 13,128 PointsThank you Andrew, it saved my life.
Miriam Tocino
14,201 PointsHi 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 :)
yuehwencheng
29,154 PointsSo helpful. Thx!
Brian Foley
8,440 PointsThank you!!!
Kenneth Love
Treehouse Guest TeacherNot 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.
Kevin Lozandier
Courses Plus Student 53,747 PointsI will also recommend http://www.regexr.com/ in addition to this resource and the ones from Lea Verou I posted earlier this week about.
Caleb King
32,777 PointsAwesome thanks team!
Cauli Tomaz
12,362 PointsReally helpful!
Adrian Hernandez
1,713 PointsVery insightful!
Ajinkya Borade
Courses Plus Student 16,635 Pointsthanks :)
Martha Garvey
1,865 PointsCool. Even more nifty content.
Aidan O'Leary
12,313 PointsVery good introduction to regular expressions.
karlcoelho
1,361 PointsThanks a lot. Regular Expressions looked really scary to me before, but now I can see how useful it is!
Alex Hedley
16,381 PointsPython course is in Development http://teamtreehouse.com/library/regular-expressions-in-python/upcoming
Ajinkya Borade
Courses Plus Student 16,635 Pointscan we have regex course on JS ?
Kevin Lozandier
Courses Plus Student 53,747 PointsAjinkya 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).
Ajinkya Borade
Courses Plus Student 16,635 Pointsalright ;)
Thomas Pane
7,804 Pointscan 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)); }
Emil Martinov
2,935 PointsEmil Martinov
2,935 PointsLea Verou's presentation looks awesome, she describes and illustrates regex beautifully. Finally I am grasping it. Thank you.