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

JavaScript Regular Expressions in JavaScript Validating a Form Validating a Password

Acknowledging online sources

Hey all,

In Joel’s course on regular expressions, he discusses how there are likely already solutions to a number of regular expression needs available online.

He provides this snippet as an example:

/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/

My question is about best practice in web development. To what extent should we be referencing or acknowledging the source when we take solutions we find online?

Interested in answer to this also!

1 Answer

Christopher Wester
seal-mask
.a{fill-rule:evenodd;}techdegree
Christopher Wester
Full Stack JavaScript Techdegree Student 4,058 Points

I am not a developer But when I go to the popular coding website StackOverflow The code posted in each question chat has a copy button that includes code attribution

// Source - https://stackoverflow.com/a/79933825
// Posted by Tuhin Shaikh
// Retrieved 2026-04-30, License - CC BY-SA 4.0

document.addEventListener('change', e => {
  if (e.target.matches('input[name="file"]')) alert('Input changed');
});

As you can see, you can place just about anything in comments Not every code snippet on the web will have a license included It is up to you to determine what you feel the need to include when you borrow code from the web.

Personally, I like the 3 lines of comments which include: Who?, Where?, When?