GithubHelp home page GithubHelp logo

parloti / typeregex Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 132 KB

Typified help in building regular expressions pattern.

License: MIT License

C# 100.00%
csharp netstandard regex regular-expression fluentregex verbal-expressions

typeregex's Introduction

TypeRegex

Typified help in building regular expressions pattern.

Typified C# Regular Expressions Pattern.

TypeRegex is a CSharp library that helps to construct regular expressions patterns reducing typos and other common mistakes.

Installation

Use the package manager NuGet to install TypeRegex.

Install-Package TypeRegex

Usage

using TypeRegex;

public class Program
{
  public static void Main()
  {
    var pattern = new Pattern()
                    .AtStartOfStringOnly()
                    .Any()
                    .NewLine(true)
                    .AtEndOfStringOnly();
    
    Console.Write(pattern);

    // The example displays the following output:
    //    "\A[\u0000-\uFFFF]\u000D?\u000A\z"
  }
};

.NET Regular Expression Element Support

Character Escapes

Official Documentation

Character or sequence Description TypeRegex
\a Alarm character, \u0007. Pattern.Alarm(), Escapes.Alarm
\a Bell character, \u0007. Pattern.Bell(), Escapes.Bell
\b Backspace, \u0008. Pattern.Backspace(), Escapes.Backspace
\t Tab, \u0009. Pattern.Tab(), Escapes.Tab
\r Carriage return, \u000D. Pattern.CarriageReturn(), Escapes.CarriageReturn
\v Vertical tab, \u000B. Pattern.VerticalTab(), Escapes.VerticalTab
\f Form feed, \u000C. Pattern.FormFeed(), Escapes.FormFeed
\n New line, \u000A. Pattern.NewLine(), Escapes.NewLine
\e Escape, \u001B. Pattern.Escape(), Escapes.Escape
\r?\n Zero or one occurrence of a carriage return followed by a new line, \u000D?\u000A. Pattern.NewLine(true), Escapes.WindowsNewLine
\ nnn ASCII character with octal code. Pattern.Octal(string octalNumber)
\x nn ASCII character with hexadecimal code. Pattern.Hexadecimal(string hexadecimalNumber)
\c X ASCII control character. Pattern.ASCIIControl(string controlCharacter)
\u nnnn UTF-16 code unit with hexadecimal value. Pattern.Unicode(string hexadecimal)
\ Escapes the followed character. Pattern.Literal(char character)

Character classes

Official Documentation

Syntax Description TypeRegex
[character_group] Positive character group. Pattern.AnyIn(string set, bool escape = true)
new PositiveCharacterGroup(string set, bool escape = true)
[character_group] Pattern.AnyIn(params char[] set)
new PositiveCharacterGroup(params char[] set)
[firstCharacter-lastCharacter] Pattern.Range(char first, char last, bool caseSensitive = true)
new PositiveCharacterGroup(char first, char last, bool caseSensitive = true)
[firstCharacter-lastCharacter] Pattern.Range(uint first, uint last)
new PositiveCharacterGroup(uint first, uint last)
[^character_group] Negative character group. Pattern.AnyNotIn(string set, bool escape = true)
new NegativeCharacterGroup(string set, bool escape = true)
[^character_group] Pattern.AnyNotIn(params char[] set)
new NegativeCharacterGroup(params char[] set)
[^firstCharacter-lastCharacter] Pattern.NotInRange(char first, char last, bool caseSensitive = true)
new NegativeCharacterGroup(char first, char last, bool caseSensitive = true)
[^firstCharacter-lastCharacter] Pattern.NotInRange(uint first, uint last)
new NegativeCharacterGroup(uint first, uint last)
. Any character Pattern.Any()
new PositiveCharacterGroup()
\p{name} Unicode Category Pattern.Add(UnicodeGroup{PositiveUnicodeCategory}.ToString())
Pattern.UnicodeGroup(UnicodeGroup{PositiveUnicodeCategory} group)
\p{name} Unicode Block Pattern.Add(UnicodeGroup{PositiveUnicodeBlock}.ToString())
Pattern.UnicodeGroup(UnicodeGroup{PositiveUnicodeBlock} group)
\P{name} Negative Unicode Category Pattern.Add(UnicodeGroup{NegativeUnicodeCategory}.ToString())
Pattern.UnicodeGroup(UnicodeGroup{NegativeUnicodeCategory} group)
\P{name} Negative Unicode Block Pattern.Add(UnicodeGroup{NegativeUnicodeBlock}.ToString())
Pattern.UnicodeGroup(UnicodeGroup{NegativeUnicodeBlock} group)
\w Word character Pattern.Word(MatchingBehavior matchingBehavior = MatchingBehavior.Default)
Pattern.ECMAScriptWord()
Pattern.UnicodeWord()
\W Non-word character Pattern.NonWord(MatchingBehavior matchingBehavior = MatchingBehavior.Default)
Pattern.ECMAScriptNonWord()
Pattern.UnicodeNonWord()
\s Whitespace character Pattern.WhiteSpace(MatchingBehavior matchingBehavior = MatchingBehavior.Default)
Pattern.ECMAScriptWhiteSpace()
Pattern.UnicodeWhiteSpace()
\S Non-whitespace character Pattern.NonWhiteSpace(MatchingBehavior matchingBehavior = MatchingBehavior.Default)
Pattern.ECMAScriptNonWhiteSpace()
Pattern.UnicodeNonWhiteSpace()
\d Decimal digit character Pattern.Digit(MatchingBehavior matchingBehavior = MatchingBehavior.Default)
Pattern.ECMAScriptDigit()
Pattern.UnicodeDigit()
\D Non-digit character Pattern.NonDigit(MatchingBehavior matchingBehavior = MatchingBehavior.Default)
Pattern.ECMAScriptNonDigit()
Pattern.UnicodeNonDigit()
[base_group - [excluded_group]] Character class subtraction Pattern.Subtraction(ISubtractable baseGroup, CharacterGroup excludedGroup)

Anchors

Coming soon

Grouping Constructs

Coming soon

Quantifiers

Coming soon

Backreference Constructs

Coming soon

Alternation Constructs

Coming soon

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

typeregex's People

Contributors

parloti avatar

Stargazers

 avatar

typeregex's Issues

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.