I stumbled upon this seemingly trivial question, and I'm stuck on it. I have a string, in which I want to match **in one regex** all uppercase words *only* if somewhere in the string there's at least a lowercase letter.

Basically, I want each of these lines (we can consider I'll apply the regex to each line separately, no need for some multiline handling) to output:

```none
ab ABC          //matches or captures ABC
ab ABC 12 CD    //matches or captures ABC, CD
ABC DE          //matches or captures nothing (no lowercase)
ABC 23 DE EFG a //matches or captures ABC, DE, EFG
AB aF DE        //matches or captures AB, DE

```

I am using PCRE as regex flavor (I know some other flavors allow for variable length look-behind).

**Update after comments**

Obviously, there are lots of easy solutions if I use multiple regex or the program language I'm using to call the regex (e.g. first validate the string by looking for a lowercase letter then match all uppercase words with two different regex).

My goal here is to find a way to do it with one regex.

I have no technical imperative for this constraint. Take it as an exercise of style if you have to, or curiosity, or me trying to up my regex skills: the task seemed (at first) *so* simple that I'd like to know if one regex alone can achieve it. If it can't, I'd like to understand why.

Or if it can but regex aren't designed for these kind of tasks, I wish I'd know why - or at least what are "these kind of unsuited tasks", so that I can choose the right solution when I meet them.

---

So, is it doable in one regex?