regx - simple command line regex tool using .NET syntax

Help Categories:


regx [/Pattern] pattern [/Replace substitution]
    [/File filespec] [/Recurse]
    [/Url] [/Fusk]
    {output options -- see below}
    {display detail options -- see below}
    {Regex options -- see below}
    [/NoWarnings] [/ErrorsToStdOut] [/Debug]


To get detailed help:
    regx help [Usage|Regex|Matching|Replacing|Format|Parameters|Version|All]


The regex matching pattern and any replacement pattern should be quoted if  they contains spaces or any special characters.
You may abbreviate /Replace as /rp

Regex options:

/CaseInsensitive (or /i)
/IgnorePatternWhitespace (or /ipw)
/RightToLeft (or /rtl)


/File can be abbreviated to /f and can take these formats:

(ommitted) Search stdin as a pipe
/f filename Search one file
/f filespec Search all matching files in a directory
/f filespec /r Search all matching files in a directory and all directories below that one, recursively
/url weburl Load the contents of a page via http or https and search that
/url urlpattern /fusk Expand a pattern of pages and search each of them

You may provide /f, /url, or neither, but may not provide both.


Selecting which lines to output:

  • /Output Matched
    The default
  • /Output All
    For replacements, usually
  • /Output Unmatched
    or /InvertResults
    or /v

Decorating lines:

  • /Details Smart
    The default. This is the same as LineNumber in filter mode or FileAndLine for files or urls
  • /Details None
    Just the line is displayed (matching or not, depending on the /Output value)
  • /Details LineNumber
    The line number is output for each output line
  • /Details FileAndLine
    The source name (filename or url) and the line number before matching line
  • /Format <format string>
    specifies a format string for displayed lines.
    Use "regx help format" to get help on format strings.

Also, you can set

  • /ShowRelativeNames
    Shortens file names to be relative to the root of the filespec.
    It is on by default. To turn it off, use /ShowRelativeNames-

You can abbreviate /Output and its values: "/out all", "/o m"
You can abbreviate /Details and its values: "/d a"


regx /patt numb(er)? /f input*.txt /i
type inputfile.txt | regx numb(er)? /v /d none
regx numb(er)? /f input*.txt /rp "Numb and number" /out all

Last edited Sep 19, 2012 at 8:26 PM by SethMorris, version 5


No comments yet.