[j-nsp] jcs:split() function with errors

Phil Shafer phil at juniper.net
Fri Jul 22 16:06:13 EDT 2011


ben b writes:
>> i'm try to find out the number of pipes "|" in all of my interface
>> descriptions, but for some reason the jcs:split() function errors out in my
>> commit script.  Does anyone have any suggestions?

jcs:split() takes a pattern (regex) instead of a simple string.  You'll
need to escape the "|" to prevent it from being interpreted in the
regex context.  You escape this using a backslash, but you also need
to escape the backslash since SLAX interprets this as _it's_ escape
character as well.  So you'll end up needing:

    var $description_parts = jcs:split("\\|", description);

Thanks,
 Phil


More information about the juniper-nsp mailing list