Summary
Strings are used across many disciplines to represent data, filenames, and other objects: they are used by linguists studying representation, classification, and patterns involved in audio and text usage; biologists working with genomic data as strings are interested in sequence structure and assembly and perform extensive statistical analysis on strings; programmers operate on string data for such tasks as text search, file manipulation, and text processing. Strings are so ubiquitous that almost every modern programming language has a string data type and dozens of functions for operating on strings.
In this chapter we will introduce the tools available for working with strings, starting with a look at their structure and syntax, then moving on to a discussion of the many high-level functions that are optimized for string manipulation. Many of the functions introduced in Chapter 3 for operating on lists have analogs with strings, and you would do well to first make sure you understand those before tackling the string functions.
String patterns follow on the discussion of more general patterns introduced in Chapter 4. We will introduce an alternative syntax – regular expressions – that provides a compact and efficient mechanism for working with strings. The chapter closes with several applied examples from bioinformatics (creating random strings, partitioning strings, analyzing GC content, displaying sequences in tables) and linguistics (text processing, corpus analysis, n-grams, collocation, word and sentence length frequency).
- Type
- Chapter
- Information
- Essentials of Programming in Mathematica® , pp. 243 - 282Publisher: Cambridge University PressPrint publication year: 2015