Regex to test that a string contains both upper case and lower case letters

You can use

<b>(?=[A-Z\s]*[a-z])(?=[a-z\s]*[A-Z])[\sA-Za-z]*(?:\(ecg\))?<\/b>

See the regex demo

Details

  • <b> – a <b> text
  • (?=[A-Z\s]*[a-z]) – after 0 or more uppercase letters or whitespaces, there must be at least one lowercase letter
  • (?=[a-z\s]*[A-Z]) – after 0 or more lowercase letters or whitespaces, there must be at least one uppercase letter
  • [\sA-Za-z]* – zero or more letters/whitespaces
  • (?:\(ecg\))? – an optional (ecg) text
  • <\/b> – a </b> text.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top