top of page

Regular Expression search for Bates numbers

The world apparently needs a good RegEx search for Bates numbers in a variety of formats. When I tried today to find one by running a Google search, I only found a lame attempt in the Relativity Search Guide which requires the entry of specific Bates prefix:

Here's a first attempt at a RegEx pattern which will account for Bates numbers with different Bates prefixes that contain hyphens and underscores between segments of the letter prefix, and which contain between 5 and 12 digits.


The search is structured to search for between 1-10 letters at the beginning of a word boundary:


. . . it then searches for either a hyphen, underscore or zero or one whitespace:


. . . between the letter prefix and 5 to 12 digit number which is at the end of a word:


The search then looks for instances where the Bates letter prefix is split in two parts, separated by a hyphen, underscore, or zero, or one whitespace:


Obviously, it's possible to imagine additional Bates number formats, but this should find most and can easily be edited to account for more variations in the letter prefix length or number of digits.


bottom of page