With Mathematica I always feel that strings are "second class citizens." Compared to a language such as PERL one must juggle a lot of code to accomplish the same task.
The available functionality is not bad but the syntax is uncomfortable. While there are a few shorthand forms such as
StringExpression, most of the string functionality lacks such syntax, and uses clumsy names like:
In Mathematica strings are handled like mathematical objects, allowing
5 "a" + "b" where
"b" act as symbols. This is a feature that I would not change, even if doing so would not break stacks of code. Nevertheless it precludes certain terse string syntax wherein the expression
5 "a" + "b" would be rendered
"aaaaab" for example.
What is the best way to make string manipulation more convenient in Mathematica?
Ideas that come to mind, either alone or in combination, are:
Overload existing functions to work on strings, e.g.
- This was the original topic of my question to which Sasha replied. It was seen as inadvisable.
Use shortened names for string functions, e.g.
Create new infix syntax for string functions, and possibly new string operations.
Create a new container for strings, e.g.
str["string"], and then definitions for various functions. (This was suggested by Leonid Shifrin.)
A variation of (4), expand strings (automatically?) to characters, e.g.
str["s","t","r","i","n","g"]so that the characters can be seen by
Call another language such as PERL from within Mathematica to handle string processing.
Create new string functions that conglomerate frequently used sequences of operations.