<p>Wanna write a RegEx to validate a driving license. </p>

<p>if it doesn't start with (US, CA, CN) then it has to be followed with XX and after that with any number of Alpha numeric letters. </p>

<p>So for example if the driving license starts with GB then it has to be followed with XX
GBXX12345363
However if it starts with US then we don't care what comes after it. 
USLA039247230</p>

```
```
/^(?:(?:US|CA|CN)\w+|[[:alpha:]]{2}XX\w+)$/
```
```
I'm not sure if there's more validation that can be done, but this is what I get from what you wrote, not your examples (which seem to imply four letters followed by numbers).