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
mikes02Courses Plus Student 16,968 Points
jQuery Regular Expression Help
Saw a challenge on Twitter so I've been working my way through it, granted I am not the best with Regular Expressions. This is what I have so far:
var pass_regex = new RegExp(/^[a-z][A-Z][0-9]|[!@#$%^&*()_]+$/);
I am trying to match a password input that contains:
- 1 Lowercase Letter
- 1 Uppercase Letter
- 1 Digit OR Special Character
Where I am getting stuck is on the 'OR' part, I thought the pipe separator between [0-9] and my set of special characters would work but it doesn't seem to.
Spencer Eldred20,271 Points
I think it decodes like this: (starts with one lowercase letter, followed by one uppercase letter, ending in an uppercase letter) OR ( one or more special case letters)
sR7 would match, and #@#%$#$ would also match
'^' - means the string starts with '$' - means the string ends with '+' - means one or more characters
I like to use the http://rubular.com/ website to test out regular expressions. You can copy your expression over to the site and create test strings and see which ones match.