Giter VIP home page Giter VIP logo

abnf's Introduction

ABNF to REGEX Library

The ABNF to REGEX library is a pair of PHP functions that validate standard ABNF (RFC 5234) input and generate POSIX and Perl-compatible regular expressions for use in schema and applications.

I provide an online form front-end for these functions at:

http://abnf.msweet.org/

The file "example.php" shows how to implement your own web form.

Functions

abnf_load(string)

This function parses the ABNF contained in the supplied string. On success, it returns an array of rules that can be passed to the "abnf_regex" function.

FALSE is returned on failure, with the following global variables describing the issue:

  • "abnf_error" contains a string describing the issue.
  • "abnf_errorline" contains the line number in the string where the issue occurred.
  • "abnf_errorcol" contains the column number in the string where the issue occurred.

abnf_regex(rules, rulename, mode = ABNF_INSENSITIVE)

This function generates a regular expression for the named rule. If the named rule does not exist, an empty string is returned.

The "mode" parameter can be any of the following constants:

  • ABNF_INSENSITIVE : Generates a case-insensitive regular expression.
  • ABNF_SENSITIVE : Generates a case-sensitive regular expression.
  • ABNF_LOWERCASE : Generates a case-sensitive regular expression with all string literals converted to uppercase.
  • ABNF_UPPERCASE : Generates a case-sensitive regular expression with all string literals converted to lowercase.

Legal Stuff

Copyright (c) 2013-2017 Michael R Sweet

This software is provided under the terms of the MIT license, which is provided in the file "LICENSE.md".

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.