19 hours ago · Tech · hide · 0 comments

Suppose you want to search for a list of words. If you’re using grep, you can add the -f flag provide a file of regular expressions, and you can add the -F to tell it that the regular expressions are in fact just words. I did something like this a couple days ago when searching for diagnosis codes. grep -w -F -o -f icd10codes.txt notes.txt Now you might want to combine your list of words into a singular regular expression, for efficiency or possibly for some other reason. Apparently ripgrep does this because when I tried replacing grep with ripgrep in the command above I got an error saying “Compiled regex exceeds size limit of 104857600 bytes.” Beating brute force Say you wanted to search for the strings “bluecross”, “blueshield”, and “bluey”. You could simply form the brute force regular expression bluecross|blueshied|bluey but that doesn’t take advantage of the fact that all three strings begin with “blue.” A smaller regular expression would be blue(shield|cross|y) Finding the…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.