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 -i option β€” 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: the STRING escaping thing is real. escape it properly or the shell will eat your argument for breakfast and yangre will 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 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 that sneaky leading space before notpat? that's the invert-match in action. chef's kiss. πŸ’…


πŸ” SEE ALSO πŸ”


πŸ‘‘ AUTHORS πŸ‘‘

Radek Krejci <rkrejci@cesnet.cz>, Michal Vasko <mvasko@cesnet.cz>

this man page was written by David Lamparter <equinox@diac24.net> 🌟


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 πŸ’–βœ¨πŸ¦‹