YANGRE(1)
π YANGRE(1) β yangre π
okay bestie, welcome to the General Commands Manual corner of the internet, section 1, and today we're talking about yangre β the YANG regular expression processor. she's small, she's focused, she's literally just here to vibe-check your regexes before they go into a YANG schema. no cap. π¦
β¨ NAME β¨
yangre β YANG regular expression processor πΈ
π SYNOPSIS π
yangre [-V] -p REGEXP [-i] [-p REGEXP [-i]...] STRING
yangre [-V] -f FILE
two modes, two moods, pick your fighter π
π DESCRIPTION π
so, what even is yangre? She's a command-line tool for testing and evaluating regular expressions for use in YANG schemas. The supported regex flavors are the ones defined by the W3C's XML-Schema standard. That's the whole point of her existence. She's not trying to be grep, she's not trying to be Perl, she is the YANG regex validator and she is thriving. β¨
You can run her two ways, bestie:
- with regular expressions and a target string right on the command line, or
- with input from a file.
And the file mode? That one is lowkey the MVP, because it lets you avoid dealing with proper shell escaping of regular expression patterns, which β and I cannot stress this enough β can be somewhat tricky. π« If you've ever stared at six backslashes in a terminal and questioned every choice that led you here, -f is your girl.
π GENERAL OPTIONS π
-h,--helpβ outputs usage help and exits. that's it, that's the tweet. π-v,--versionβ outputs the version number and exits. iconic behavior honestly. π-V,--verboseβ increases the verbosity level. if you don't specify it, only errors are printed. each time you add it, it stacks on another layer: warnings, then verbose messages, then debug messages (that last one only if it was compiled with debug information). it's giving "volume knob but make it diagnostics" π₯
π¬ COMMAND LINE INPUT π¬
-p REGEXP,--pattern=REGEXPβ one or more regular expression patterns to be tested against the input string. the supplied expressions are tested in the order they appear on the command line, and testing is aborted when an expression does not match (or does match, if you used the-ioption β plot twist π).-i,--invert-matchβ reverse the match condition for the previous pattern. so if the pattern matches, an error is printed and evaluation is aborted. yes, she flips the whole script. π- STRING β the 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β so if it contains spaces or other shell metacharacters, they must be properly escaped. and the extra arguments? silently ignored. π not even a little acknowledgment. rude but efficient.
heads up bestie: theSTRINGescaping thing is real. escape it properly or the shell will eat your argument for breakfast andyangrewill never even know it existed. π
π FILE INPUT π
-f FILE,--file=FILEβ read both patterns and target text from the specified input file.
okay so here's the β¨formatβ¨, pay attention:
FILE must consist of one or more YANG regular expressions, each on their own line, followed by a blank line and then one line of target text.
and now the part where she's a little strict:
- no preprocessing is done on file input π«
- there are no comment lines π«
- 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. sneaky little space, doing the most. π«Ά
and patterns must still be properly quoted as mandated by the YANG standard. rules are rules, bestie.
β RETURN VALUES β
0β Successful match. the target text matched for all patterns. slay. π1β Pattern mismatch. one or more patterns did not match the target text. an error message is printed tostderrdescribing 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 that sneaky leading space before notpat? that's the invert-match in action. chef's kiss. π
π 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.
and that's the whole page, bestie!! π this was libyang, dated 2018-11-09, page YANGRE(1) β go forth and regex responsibly, and remember: escape your strings, respect the blank line, and never trust a leading space. mwah πβ¨π¦
π¦ where this page comes from
- alpine 3.24: libyang-doc 3.13.6-r1 Β· BSD-3-Clause-Clear
- centos-stream 9: libyang 2.1.148-3.el9 Β· BSD
- centos-stream 9: libyang 2.1.148-3.el9 Β· BSD
- debian bookworm: libyang2-tools 2.1.30-2 Β· BSD-3-Clause
- debian trixie: libyang3-tools 3.12.2-1 Β· BSD-3-Clause
- fedora 43: libyang-tools 3.12.2-1.fc43 Β· BSD-3-Clause
- fedora 44: libyang-tools 3.13.5-2.fc44 Β· BSD-3-Clause
- nixos 26.05: libyang 3.13.6
- nixpkgs unstable: libyang 3.13.6
- opensuse-leap 16.0: yang-tools 2.1.148-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: yang-tools 2.1.148-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: yang-tools 2.1.148-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: yang-tools 2.1.148-160000.4.1 Β· BSD-3-Clause
- ubuntu jammy: libyang2-tools 2.0.112-6ubuntu2 Β· BSD-3-Clause
- ubuntu noble: libyang2-tools 2.1.30-2.1build1 Β· BSD-3-Clause
- ubuntu noble: libyang2-tools 2.1.30-2.1ubuntu0.1 Β· BSD-3-Clause
- ubuntu questing: libyang3-tools 3.13.5-2
- ubuntu questing: libyang3-tools 3.13.5-2ubuntu0.1
- ubuntu resolute: libyang3-tools 3.13.6-1 Β· BSD-3-Clause
- ubuntu resolute: libyang3-tools 3.13.6-1ubuntu0.1 Β· BSD-3-Clause
- ubuntu stonking: libyang-tools 6.1.4-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms