[j-nsp] negation operator in SLAX

Martin T m4rtntns at gmail.com
Thu Jun 14 17:39:30 EDT 2018


Hi!

I have quite often used "!" negation operator familiar from other
languages. For example:

/* If string does not match the pattern, then terminate the script. */
if ( ! jcs:regex( $pattern, $string ) )  {
    terminate 'Invalid input string!';
}

However, I have not found this method in the official SLAX
documentation or SLAX operators list. Based on my example above, the
suggested solution seems to be to check if jcs:regex returned an empty
node-set or not using jcs:empty:

if ( jcs:empty( jcs:regex( $pattern, $string ) ) ) {
    terminate 'Invalid input string!';
}

Just out of curiosity, is there a difference between those two methods?


thanks,
Martin


More information about the juniper-nsp mailing list