Search Tools

Table of Contents

Details

.ignore

Most search tools like ag and rg comply with .ignore, which is formatted same as .gitignore. Tools will ignore targets specified in .ignore

Expressions

.
?
*
+
{n}
{n,}
{,m}
{n,m}
[:upper:] A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[:lower:] a b c d e f g h i j k l m n o p q r s t u v w x y z
[:digit:] 0 1 2 3 4 5 6 7 8 9
[:xdigit:] 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
[:punct:] ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { ¦ } ~ (Punctuation characters)
[:blank:] space and tab
[:space:] tab, newline, vertical tab, form feed, carriage return, and space
[:alpha:] [:lower:] and [:upper:]; same as [A-Za-z]
[:alnum:] [:alpha:] and [:digit:], same as [0-9A-Za-z]
[:graph:] [:alnum:] and [:punct:] (Graphical characters)
[:print:] [:alnum:], [:punct:], and space
[:cntrl:] Octal codes 000 through 037, and 177 (DEL)
\b Match the empty string at the edge of a word
\B Match the empty string provided it’s not at the edge of a word.
\< Match the empty string at the beginning of word.
\> Match the empty string at the end of word.
\w A synonym for [_[:alnum:]]
\W A synonym for [^_[:alnum:]]
\s A synonym for [[:space:]]
\S A synonym for [^[:space:]]
(a)\1 Matches aa (Back references)
a(.)¦b\1 will not match ba (Only groups participated in the match can be back-referenced)

Meta Characters that require escaping when using as literal characters

PCRE, ERE, and other compatibles

BRE (POSIX Basic Regular Expressions)

Tools

ag(The Silver Searcher)

rg(ripgrep)

Links