.\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . .TH "REGEX" "1" "October 2011" "" "" . .SH "NAME" \fBregex\fR \- regular expression tool . .SH "DESCRIPTION" Regex is a simple commmandline Regular Expression tool, that makes it easy to search documents for content matches\. . .P Yea, I know what you are going to say\. "I can do that with ____" Fill in the blank with +grep+, +awk+, +sed+, +perl+, etc\. But honestly, none of these tools are as straight forward and capable as one might want\. What is needed is a simple command\-line tool that gives quick access to a Regular Expression engine\. No more, no less\. . .P Now this could have written this in Perl\. No doubt, it would be just as good, if not better since Perl\'s Regualar Expression engine rocks (or so it is said)\. But Ruby\'s is pretty damn good too, and getting better (with 1\.9+)\. And since your humble author knows Ruby very well\.\.\.\. Well that\'s what you get\. . .SH "OPTIONS" The \fBregex\fR command line has the following options\. . .SS "Search Options" . .IP "\(bu" 4 \fB\-s\fR, \fB\-\-search PATTERN\fR \- Search for this pattern\. . .IP "\(bu" 4 \fB\-t\fR, \fB\-\-template NAME\fR \- Use a built\-in regular expression (instead of \fB\-s\fR)\. . .IP "\(bu" 4 \fB\-i\fR, \fB\-\-insensitive\fR \- Case insensitive matching\. . .IP "\(bu" 4 \fB\-m\fR, \fB\-\-multiline\fR \- Multiline matching\. . .IP "\(bu" 4 \fB\-g\fR, \fB\-\-global\fR \- Global search\. By default regex only searches for the first match\. Use the global option to search for all matches\. . .IP "\(bu" 4 \fB\-e\fR, \'\-\-escape\' \- Make all patterns verbatim string matchers\. . .IP "\(bu" 4 \fB\-n\fR, \fB\-\-index INT\fR \- Return a specific match index\. . .IP "\(bu" 4 \fB\-R\fR, \fB\-\-recursive\fR \- Search though subdirectories recursively\. . .IP "\(bu" 4 \fB\-y\fR, \fB\-\-yaml\fR \- Output in YAML format\. . .IP "\(bu" 4 \fB\-j\fR, \fB\-\-json\fR \- Output in JSON format\. . .IP "\(bu" 4 \fB\-d\fR, \fB\-\-detail\fR \- Provide match details\. . .IP "" 0 . .SS "Replace Options" . .IP "\(bu" 4 \fB\-r\fR, \fB\-\-replace TEXT\fR \- Replace matching pattern with the given text\. . .IP "\(bu" 4 \fB\-b\fR, \fB\-\-backup\fR \- Backup any files that are changed\. . .IP "" 0 . .SS "Special Options" . .IP "\(bu" 4 \fB\-\-[no\-]ansi\fR \- Toggle ansi color\. . .IP "\(bu" 4 \fB\-\-debug\fR \- Run in debug mode\. . .IP "\(bu" 4 \fB\-h\fR, \fB\-\-help\fR \- Display this lovely help message\. . .IP "" 0 . .SH "OUTPUT" Regex has three output modes\. YAML, JSON and standard text\. The standard text output is unique in that it utilizes special ASCII characters to separate matches and regex groups\. ASCII 29, called the \fIrecord separator\fR, is used to separate repeat matches\. ASCII 30, called the \fIgroup separator\fR, is is used to separate regular expression groups\. . .SH "EXAMPLES" The following example returns the content between the first \fB=begin \.\.\. =end\fR clause it comes across\. . .P $ regex \'/=begin\.\fI?\en(\.\fR)\en=end/\' sample\.rb . .P Instead of the first argument being the regular expresion, we can use the \fB\-s\fR option\. This exampe finds the first line starting with a Q\. . .P $ regex \-s \' sample\.txt . .P This example would replace all words starting with an X with an A in all \.txt files in the current directory\. . .P $ regex \-g \-s \'\ebX\' \-r \'A\' *\.txt . .SH "COPYRIGHTS" Copyright (c) 2009 Thomas Sawyer, Rubyworks . .P Regex is distributable in accordance with the terms of the BSD\-2\-Clause license\.