An unofficial extension for providing handy string-related primitives in NetLogo.
see https://github.com/NetLogo/String-Extension/releases
The following reporters are provided:
explode
-- turns a string into a list (of one-character strings)from-file
-- read an entire file into a string with one commandfrom-list
-- turns a list into a stringhash-code
md5
-- generate the MD5 hash for a stringrex-match?
-- search in strings using standard regular expressionsrex-replace-first
,rex-replace-all
,rex-split
starts-with?
,ends-with?
-- match a string against the start or end of another stringtrim
-- removes initial and trailing whitespaceupper-case
,lower-case
-- alter the letter case of stringssplit-on
-- reports a list formed by splitting string using the string-delimiter
To build the source code, run sbt compile
.
To run the tests in tests.txt
, add the extension, go to the NetLogo directory, and run sbt 'te string'
.
To build a release package, run sbt package
.
Ideas for possible additional primitives:
ascii-code <character>
-- returns the ASCII index of the given character (the first character of the string), or 0 for non-ASCII charactersfrom-ascii <integer>
-- returns the ASCII character corresponding to the given small integer indexlast-index-of <needle> <haystack>
-- reports the index of the last occurrence of needle in haystack, or false, if needle does not occurposition-regex <regex-needle> <haystack>
The string extension was written by James Steiner of turtleZERO.com.
The NetLogo string extension is in the public domain. To the extent possible under law, James Steiner has waived all copyright and related or neighboring rights.