YANGRE(1)

NAME
yangre - YANG regular expression processor

SYNOPSIS
yangre [-V] -p REGEXP [-i] [-p REGEXP [-i]...] STRING
yangre [-V] -f FILE

DESCRIPTION
yangre is a command-line tool to test and evaluate regular expressions for use in YANG schemas. Supported regular expressions are defined by the W3C's XML-Schema standard.

yangre can be used either with regular expressions and a target string on the command line or with input from a file. The latter is particularly useful to avoid dealing with proper shell escaping of regular expression patterns, which can be somewhat tricky.

GENERAL OPTIONS

-h, --help
    Outputs usage help and exits.

-v, --version
    Outputs the version number and exits.

-V, --verbose
    Increases the verbosity level. If not specified, only errors are printed, with each appearance it adds: warnings, verbose messages, debug messages (if compiled with debug information).

COMMAND LINE INPUT

-p REGEXP, --pattern=REGEXP
    One or more regular expression patterns to be tested against the input string. Supplied expressions are tested in the order they appear on the command line. Testing is aborted when an expression does not match (or does match, if the -i option is used.)

-i, --invert-match
    Reverse match condition for the previous pattern. If the pattern matches, an error is printed and evaluation is aborted.

STRING
    Target text input to match the regular expression(s) against. The same text is used for all regular expressions. Note that only the first argument is used by yangre, if it contains spaces or other shell metacharacters they must be properly escaped. Additional arguments are silently ignored.

FILE INPUT

-f FILE, --file=FILE
    Read both patterns and target text from the specified input file.

    FILE must consist of one or more YANG regular expressions, each on their own line, followed by a blank line and one line of target text. No preprocessing is done on file input, there are no comment lines and whitespace is not stripped. A single space character at the beginning of a pattern line inverts the match condition for the pattern on that line. Patterns must still be properly quoted as mandated by the YANG standard.

RETURN VALUES

0   Successful match
    The target text matched for all patterns.

1   Pattern mismatch
    One or more patterns did not match the target text. An error message is printed to stderr describing which pattern was the first not to match.

255 Other error
    One or more patterns could not be processed or some other error occurred that precluded processing.

EXAMPLES

•   Test a single pattern:
        yangre -p 'te.*xt' text_text

•   Test multiple patterns:
        yangre -p '.*pat1' -p 'pat2.*' -p 'notpat' -i pat2testpat1

•   Input from a file:
        cat > /tmp/patterns <<EOF
        .*pat1
        pat2.*
         notpat

        pat2testpat1
        EOF
        yangre -f /tmp/patterns

SEE ALSO
https://github.com/CESNET/libyang (libyang homepage and Git repository)

AUTHORS
Radek Krejci <rkrejci@cesnet.cz>, Michal Vasko <mvasko@cesnet.cz>
This man page was written by David Lamparter <equinox@diac24.net>

COPYRIGHT
Copyright © 2015-2018 CESNET, a.l.e.