I am trying to determine if a string has more than 1 capital letter in a row at the start of a string. I have the following regex but it doesn’t work:
`^[A-Z]{2,1000}`
I want it to return true for:
- ABC
- ABc
- ABC ABC
- ABc Abc
But false for:
- Abc
- AbC
- Abc Abc
- Abc ABc
I have the 1000 just because I know the value won’t be more than 1000 characters, but I don’t care about restricting the length.
I am working with PHP, if it makes any difference.
Wouldn’t leaving the second one do it?
Which basically says “string starts with 2 or more capital letters”
Here’s some tests with the strings you provided that should match:
And then the ones it shouldn’t match for:
If you only want to match the first two, you can just do
{2}