Regular Expression for checking if the string contains at least one upper case

for checking if a string contains at least one upper case in javascript using .test method,
are /(?=.*?[A-Z]).*/.test("eXample") equals to /[A-Z]/.test("eXample") ? Because someone argued to me that /[A-Z]/.test("eXample") is not enough for testing if string contains at least on upper case but i doubt that if it is true if we just want to get the boolean of the test

Yes, /[A-Z]/.test("eXample") is enough for testing if a string contains at least an upper case letter.

Just to add, the first one matches a capital letter with any number of characters before and after it in a single line… the second one just matches to any single capital letter in the whole string… Should not make a difference for just .test… but if you were using .match, the first would return a whole line including the capital, where as the second would only return the single capital letter.

If you want to play with regex and learn more… this site is pretty cool .

have you guys stopped using codepen for the testing??

Hey there! Welcome to the forums :wave: :slightly_smiling_face:

Probably better to ask separate questions in a new topic…

To answer your question though…
From what I understand they just recently changed the course work to not rely on sites like Codepen or Replit. Which is probably good 'cause it limits the number of things the site relies on to run right.

One major difference I’ve seen is when you past HTML and CSS into a lesson, you have to include the link to the CSS in the HTML:

<link rel="stylesheet" href="styles.css" type="text/css">

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.