There's an awesome answer in this question by @BartKiers where he builds a function to construct these type of regexes that need to match ranges of x to y. His logic transfers nicely to text ranges and is tested in PCRE dialect at regex101.com.
The regex:
^(?:[A-Z]|[A-Z][A-Z]|[A-X][A-F][A-D])(?:[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|10[0-3][0-9][0-9][0-9][0-9]|104[0-7][0-9][0-9][0-9]|1048[0-4][0-9][0-9]|10485[0-6][0-9]|104857[0-6])$
Which basically says:
Columns part: A-Z
, or A-Z
with A-Z
, or A-X
with A-F
with A-D
Rows part: 1-9
, or 1-9
with 0-9
, or 1-9
with 1-9
with 0-9
etc all the way to the max of 104857
with 0-6
It matches the following:
A1
AA11
AAA111
ZZ12
YY1048575
XFD1048576
It will not match the following:
A0
AA01
AAZ1111111
XFD1048577
XFE1048576
ZZZ333
ZZZ9999999
Here's the diagram:
[a-zA-Z]+
will allowAB
, orA
, oraBc
, etc.\d+
will allow1
,32
,333
, etc. You can use regex101 to test, regex101.com/r/8OQVBs/1, with update regex101.com/r/8OQVBs/2 – Heddy^[a-zA-Z]+\d+$
or even^[a-zA-Z]+\d+\z
– PriscillapriseXFD
columns. This might not be that easy with a regex. – Priscillaprise