Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install paragrep

How to install paragrep

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install paragrep
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
3.0.7
3.1.1Never BuiltWhy not?
3.0.7 Available View build log
3.0.6 Available View build log
3.0.4 Available View build log
Windows (64-bit)
3.0.7
3.1.1Never BuiltWhy not?
3.0.7 Available View build log
3.0.6 Available View build log
3.0.4 Available View build log
Mac OS X (10.5+)
3.0.7
3.1.1Never BuiltWhy not?
3.0.7 Available View build log
3.0.6 Available View build log
3.0.4 Available View build log
Linux (32-bit)
3.1.1 Available View build log
3.0.7 Available View build log
3.0.6 Available View build log
3.0.4 Available View build log
Linux (64-bit)
3.1.1 Available View build log
3.0.7 Available View build log
3.0.6 Available View build log
3.0.4 Available View build log
 
License
BSD-style license
Dependencies
Imports
Lastest release
version 3.1.1 on Nov 23rd, 2012

paragrep - Paragraph Grep utility

Usage

paragrep [-aiov] [-p eop_regexp] [-e regexp] ... [-f exp_file] ... [file ] ...

paragrep [-iv] [-p eop_regexp] regexp [file] ...

Options
-a, --and Logically AND all regular expressions
-e regexp, --regexp=regexp, --expr=regexp
 Specify a regular expression to find. This option may be specified multiple times.
-f expr_file, --file=expr_file
 Specify a file of regular expressions, one per line.
-h, --help Show this message and exit
-i, --caseblind
 Match without regard to case
-o, --or Logically OR all regular expressions
-p eop_regexp, --eop=eop_regexp
 Specify an alternate regular expression to match the end of a paragraph. Default: ^\s*$
-v, --negate Negate the sense of the match.

—version Display version and exit.

Description

paragrep is a paragraph grep utility. It searches for a series of regular expressions in a text file (or several text files) and prints out the paragraphs containing those expressions. Normally paragrep displays a paragraph if it contains any of the expressions; this behavior can be modified by using the -a option.

By default, a paragraph is defined as a block of text delimited by an empty or blank line; this behavior can be altered with the -p option.

If no files are specified on the command line, paragrep searches standard input.

This is the third implementation of paragrep. The first implementation, in 1989, was in C. The second implementation, in 2003, was in perl. This is the latest and greatest.

Options in Detail
-a

The and option: Only display a paragraph if it contains all the regular expressions specified. The default is to display a paragraph if it contains any of the regular expressions. See the -o option, below.

-e expression

Adds a regular expression to the set of expressions to use when matching paragraphs. More than one -e argument may be specified. If there's only one expression, the -e may be omitted for brevity. (Think sed.)

-f expfile

Specifies a file containing regular expressions, one expression per line. Each expression in the file is added to the set of expression against which paragraphs are to be matched. More than one -f argument is permitted. Also, -f and -e may be specified together.

-i

Considers upper- and lower-case letters to be identical when making comparisons.

-o

The or option: Display a paragraph if it contains any the regular expressions specified. Since this option is the default, it is rarely specified on the command line. It exists primarily to negate the effect of a previous -a option. (e.g., If you've defined an alias for paragrep that specifies the -a option, -o would be necessary to force the or behavior.)

-p eop_expression

Specifies a regular expression to be used match paragraph delimiters. Any line that matches this regular expression is assumed to delimit paragraphs without actually being part of a paragraph (i.e., lines matching this expression are never printed). If this option is not specified, it defaults to:

^[ \t]*$

which matches blank or empty lines. (\\t represents the horizontal tab character. If you need to specify a horizontal tab, you'll need to type the actual character; paragrep doesn't recognize C-style metacharacters.)

-v

Displays all lines that do not match specified expressions. The negation logic works on DeMorgan's Laws. Normally, if -a is specified, paragrep uses the following logic to match the paragraph:

match = contains(expr1) AND contains(expr2) ...

Specifying -v along with -a changes this logic to:

match = lacks(expr1) OR lacks(expr2) ...

Likewise, without -a or -v (i.e., using -o, which is the default), the matching logic is:

match = contains(expr1) OR contains(expr2) ...

Negating that logic with -v causes paragrep to match paragraphs with:

match = lacks(expr1) AND lacks(expr2) ...

See Also

Subscribe to package updates

Last updated Nov 23rd, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.