String Theory, a string library for OpenSCAD
thingiverse
This library is a spin off from my other OpenSCAD library, Relativity. I required a string processing library to implement more advanced features, but none met my expectations so I built it myself using earlier work by roipoussiere. The library includes the following functions: before(string, end), after(string, start), between(string, start, end), substring(string, start, length), upper(string), lower(string), is_empty(string), is_null_or_empty(string), is_null_or_whitespace(string), equals(this, that, ignore_case=false), starts_with(string, start, ignore_case=false), ends_with(string, end, ignore_case=false), reverse(string), trim(string), parse_int(string, base), tokenize(string, index), join(strings, delimiter), split(string, separator=" ", ignore_case = false), index_of(string, goal, ignore_case=false, regex=false), contains(string, substring, ignore_case=false, regex=false), replace(string, replaced, replacement, ignore_case=false, regex=false), grep(string, pattern), peg(string, grammar). All functions are compatible with the latest OpenSCAD production release, 2015.03, and no dev release is needed. Those using version 2014.03 can still use an older version by checking project history on Github. The library's code shares its repository with relativity.scad: https://github.com/davidson16807/relativity.scad/blob/master/strings.scad 02/14/2015. Happy Valentine's Day! The peg() function has been added, providing support for parsing expression grammars. These allow you to create your own mini programming languages within OpenSCAD. The engine is currently too slow for complex languages using Backus-Naur form, but for now you can specify grammars in an intermediate format with nested lists. For example, _rx_peg in string.scad describes the regular expression grammar used within strings.scad to parse regex. More documentation is available here 03/17/2015. Happy Patty's Day! Thanks to new functionality in 2015.03, all string processing functions return a list of strings where appropriate. For example, grep() now returns a list of strings matching the input regex. 11/27/2014 Thanksgiving update: Regex supports negative character sets ("[^aeiou]"), character ranges ("[a-z]"), and curly bracket repetition (".{2,3}"). 11/13/2014 Regular expression engine has been added. It supports basic regex operators ("|", "*", "+", "?", "."), anchors ("^", "$"), character sets("[...]"), metacharacters("d","s", "w"), parentheses, and operator precedence. Regex functionality is available in functions where ever there is a "regex" parameter flag in a method's signature, and of course, through grep().
With this file you will be able to print String Theory, a string library for OpenSCAD with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on String Theory, a string library for OpenSCAD.