String Theory, a string library for OpenSCAD

String Theory, a string library for OpenSCAD

thingiverse

This library is a spin off of Relativity, my other OpenSCAD library. I needed a string processing library for some more advanced features I wanted to implement, and since none were available to my liking I rolled my own with help from some 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, seperator=" ", 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 production release of OpenSCAD, 2015.03. No dev release needed. For those still using version 2014.03, you can still use the older version of the library by checking the project history on Github. Code shares its repository with relativity.scad: https://github.com/davidson16807/relativity.scad/blob/master/strings.scad 2/2/2015 That right woodchuck chuckers, it's Groundhog's Day. A new function has been added, called peg(). This function offers support for parsing expression grammars. Parsing expression grammars allow you to create your own mini programming languages within OpenSCAD. The engine is currently too slow to describe complex languages using Backus-Naur form, but for now you can specify grammars using an intermediate format that uses nested lists. Look to _rx_peg in the string.scad source code for an example grammar - this is the grammar used within strings.scad to describe regular expressions. You can also find some nacent documentation available here 3/17/2015 Happy Patty's Day. Thanks to new functionality in 2015.03, all string processing functions return a list of strings, where appropriate; e.g. grep() now returns a list of strings matching the input regex. 11/27/2014 Thanksgiving update. Regex now supports negative character sets ("[^aeiou]"), character ranges ("[a-z]"), and curly bracket repetition (".{2,3}"). 11/13/2014 Added regular expression engine. The engine supports all basic regex operators ("|", "*", "+", "?", "."), anchors ("^", "$"), character sets ( "[...]"), metacharacters ("d","s", "w"), parentheses, and operator precedence. Regex functionality is exposed where ever there is a "regex" parameter flag in a method's signature, and of course, through grep().

Download Model from thingiverse

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.