Regex
Created: 2017-05-12 15:09:26 -0700 Modified: 2019-01-04 09:59:37 -0800
Matching number ranges (reference)
Section titled Matching number ranges (reference)This isn’t possible with something like [16-31]. Instead, to get a range of 16-31, you would do something like this:
(1[6-9]|2[0-9]|3[0-1])
Non-greedy search (i.e. using the ”?” character)
Section titled Non-greedy search (i.e. using the ”?” character)5/12/2017
Suppose you have text like this:
game_serversrcmain.js main.js .js Modified 38 302
account_serversrcdatabasewrapper.js databasewrapper.js .js Modified 223 216
account_serversrcserver.js server.js .js Modified 188 178
clientpublicjavascriptsmain.js main.js .js Modified 442 74
You want to find the first number in each column. You know you want something like ^.*d to find all characters leading up to the first digit, but that’s greedy by default, so it will select an entire line (i.e. all the way to the last digit). To make it non-greedy, add a ’?’ like this: ^.*?d
This will select everything up to and including the first digit found on a line.