Regex search for all years mentioned

I want to search for all the Year references that I have made in my notes.
Most of them are b/w 1000 to 2018.
How can I use Regex to do this? Please help

Do you need Regex for this? I would expect a search like “1000” OR “1001” would work.

Or are you hoping to literally search for all years from 1000 to 2018? In which case, I can see the value of a Regex, just to make the query shorter.

If all target terms are four-digit numbers, something like [0-9]{4} should work.

If you’re looking for specific year ranges, e.g., 1100-1500, you could do 1[1-5][0-9][0-9]. Note the pattern. Regex interprets that as four tokens: 1, [1-5], [0-9], [0-9]. It looks for each of those in the order specified. Square brackets and a character range means that the search should pick up any character in that range for the token. So, the search looks for four characters in a row, the first of which is 1, the second is any character between 1 and 5 inclusive, and the third and fourth are any character between 0 and 9. (Note that I’m not using number here—far as I know, regex doesn’t really understand numeracy.)

When lost, open up a tool like, put in some sample text including your search targets, and then fiddle with the cheat sheet open. It is like a useful puzzle.


Thanks!! Apparently I hadnt added the ‘’ infront of the regex expression and that is why my expressions werent working!

1 Like