[Bro] str_split

Vern Paxson vern at icir.org
Thu May 29 07:58:35 PDT 2008

>    Actually, the string is splitted but, if I got it right, the order of
>    splitted chars is not guaranteed.

Not quite.  Since it's a table[count], it's implemented as a hash table,
and prints out in an arbitrary order.  However, if you iterate from
1 .. its length, you can pull out its elements in order.  (I thought there
was a built-in that makes doing this easy, but I'm not seeing it. :-( )

> Moreover, what are those empty
>    slots?

The characters of the original string!

The semantics of split_all is that it splits on anything that matches
the regular expression, returning the strings between the split points
intermingled with the separators themselves.  For split_all("foobar", /./),
*every* character is a separator, so the strings between split points are
empty, and the original characters show up in the separator (even) slots.


More information about the Bro mailing list