Git Product home page Git Product logo

regexlineextractor's Introduction

RegexLineExtractor

Reads all lines from a source file and for every line that matches the provided pattern(s), writes that match to a destination file to a results directory.

Optimizes for concurrency by using System.Threading.Channels.

Setup

  1. Clone the repository locally.
  2. Create a pattern file that contains the .NET supported regular expression patterns you'd like to use for each line.
  3. Provide a source text file to read from.

Usage

dotnet run source-file.txt patterns.regex

patterns.regex is optional and will default to the above if omitted.

Pattern Files

A "pattern" file should contain a regular expression for each line.

Example

^\.+ end of line.
^Result: (?<output>\.+)

The above pattern file will:

  1. For each line that ends in " end of line." and write them to results/pattern-1.lines.txt.

  2. If the first pattern is not a match, does it start with "Result: " and if so write the output* group to results/pattern-2.lines.txt.

  3. If no more patterns to match against then write the line to results/not-matched.lines.txt.

* If a pattern contains a named match called output, only that group will end up in the destination file.

regexlineextractor's People

Contributors

electricessence avatar

Stargazers

GJORGJI DIMITROV avatar

Watchers

 avatar Ajay Mehta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.