Git Product home page Git Product logo

buildregex's Introduction

Build Regex

Class that allows you to build a regex string from understandably named methods. Allows for advanced regex operations and opens regex up for everyone without knowing the advanced parts of it. It will be treated similar to a query system or key word class builder syntax. Inspiration for this project is magic-regexp.

"""
?Character classes
([xyz] or [a-z]) Character class matching one of enclosed characters
    !chars()
([^xyz] or [^a-z]) negated for complemented character class
    !not.chars()
(.) Matches any single character that isn't a line terminator
    !any()
(\d) Matches any digit == ([0-9])
    !digit()
(\D) Matches any character that is not a digit == ([^0-9])
    !not.digit()
(\w) Matches any alphanumeric character from basic Latin alphabet == ([A-Za-z0-9_])
    !word_char()
(\W) Matches any character that is not a word character from basic Latin alphabet == ([^A-Za-z0-9_])
    !not.word_char()
(\s) Matches signle white space. Space, tab, form feed, line feed, ==
    ([ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
    !whitespace()
(\S) Matches a signle character other than white space ==
    ([^ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
    !not.whitespace()
(\t) Horizontal tab
    !htab()
(\r) Carriage return
    !cr()
(\n) Line feed
    !new_line()
(\v) Vertical tab
    !vtab()
(\f) Form feed
    !form_feed()
([\b]) Backspace
    !backspace()
(\0) NUL
    !nul()
(\cX) Matches control character using caret notation where X == [A-Z]. \cM == "\r" in "\r\n"
    !control()
(\xhh) Matches character with two hexadecimal digits
    !hex_2()
(\uhhhh) Matcches UTF-16 code-unit. Four hexadecimal digit
    !utf_16()
(\u{hhhh} or \u{hhhhh}) Only when u is set. Matches unicode value U+hhhh or U+hhhhh
    !unicode()
(\) Escape
    !exactly()
(x|y) Disjunction. either "x" or "y"
    !or()

?Boundry Assertions
(^) begin
    !begin()
($) end
    !end()
(\b) word boundry
    !wb()
(\B) non-word boundry
    !not.wb()

?Assertions
(?=) look ahead
    !before()
(?!) negative lookahead
    !after()
(?<=) lookbehind
    !not_before()
(?<!) negative lookbehind
    !not_after()

?Groups and backreferences
(x) Capturing group
    !capture()
(?<Name>x) Named capturing group
    !capture("name")
(?:x) non capturing group
    !group()
(\n) where n is a number. A back reference to the last substring matching the n parenthetical
    !ref(n>=0)
(\k<Name>) A back reference to the last substring matching the Named capture group
    !ref("name")

?Quantifiers
(*) 0 or more
    !noneOrMore()
(+) 1 or more
    !oneOrMore()
(?) matches the preceding object 0 or 1 times
    !optional()
({n}) matches exactly n occurrences
    !times()
({n,}) matches at least n occurrences
    !times.atLeast()
({n,m}) matches at least n and up to m occurrences
    !times.range()
\? following *, +, ?, {n}, {n,}, {m,n} makes the quantifiers stop after first match. Makes them non greedy

!maybe(), word(), options(), letter 
"""

buildregex's People

Contributors

tired-fox avatar

Stargazers

 avatar

Watchers

 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.