[j-nsp] negation operator in SLAX

Timur Maryin timamaryin at mail.ru
Fri Jun 15 04:00:11 EDT 2018


Hi Martin,


There is not() :


https://www.juniper.net/documentation/en_US/junos/topics/reference/scripting/junos-script-automation-function-xslt-not.html



On 14-Jun-18 23:39, Martin T wrote:
> 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?
> 
> 




More information about the juniper-nsp mailing list