Substring
A substring is a contiguous sequence of characters contained within a larger string or character sequence.
Get Programming: Learn to code with Python
A substring is a contiguous sequence of characters extracted from a string.
- How it is used
- Extracts and locates parts of strings to process names and larger bodies of text.
- How deep it goes
- Works through slice bounds and steps, then explains find() and rfind() results.
- Examples
- Uses "Python rules!" slices, word searches, and full names split for a name-mashup program.
- What you can do after
- Build it from scratch: split input names into stored parts and combine them in a name-mashup program.
Read how Get Programming: Learn to code with Python explains substring →
Advanced Algorithms and Data Structures
A substring is a contiguous sequence of characters contained within a string.
- How it is used
- Uses substrings to advance trie and radix-trie searches through character paths and multi-character edge labels.
- How deep it goes
- Explains recursive decomposition, terminal checks, failed paths, and radix common-prefix cases, but does not develop general substring algorithms.
- Examples
- Uses recursive first-character splitting, missing-edge failure, intermediate-node failure, and four radix edge-matching cases.
- What you can do after
- Apply it via trie or radix-trie search to follow complete keys and diagnose prefix or edge-matching failures.
Read how Advanced Algorithms and Data Structures explains substring →
The Well-Grounded Rubyist, Fourth Edition
A substring is a contiguous sequence of characters extracted from a string or string-like value.
- How it is used
- Supports Ruby string inspection, extraction, searching, removal, and replacement.
- How deep it goes
- Explains indexes, lengths, ranges, searches, mutation, and regexp matching, while deferring detailed regular-expression syntax.
- Examples
- Uses irb examples for character indexes, ranges, literal and regexp searches, deletion, and replacement.
- What you can do after
- Apply it via Ruby's [], slice, slice!, and []= methods to inspect and edit string content.
Read how The Well-Grounded Rubyist, Fourth Edition explains substring →
Learn C++ by Example
A substring is a contiguous sequence of characters taken from a string.
- How it is used
- Uses substrings to locate overlapping dictionary words in a small answer-smash game.
- How deep it goes
- Explains substring extraction through working C++ code, prefix comparison, repeated offsets, and a no-match result.
- Examples
- Demonstrates word.substr(1) producing "har", matching "harsh", and shortening "struct" through successive offsets.
- What you can do after
- Apply it via C++ string APIs to extract prefixes, compare stems, and assemble overlapping words.
100 Go Mistakes and How to Avoid Them
A substring is a contiguous portion of a string obtained through a string operation such as slicing.
- How it is used
- Diagnoses incorrect byte indexing and memory retention when extracting portions of Go strings.
- How deep it goes
- Explains byte-versus-rune slicing and shared backing arrays, then demonstrates copying; it does not specify compiler-independent sharing behavior.
- Examples
- Uses Hello, World!, multibyte Hêllo, and UUID-prefixed log messages to expose byte indexing and retention effects.
- What you can do after
- Diagnose substring-related retention and choose byte slicing, rune conversion, or copying for the situation.
Read how 100 Go Mistakes and How to Avoid Them explains substring →
Related concepts
- slicingproduced by · Slicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.
- findused by · find is a Python string method that returns the lowest index of a specified substring, or -1 when the substring is absent.
- splitproduced by · Split is an operation or function that divides a string or sequence into parts according to a separator, pattern, or other rule.
- replace methodused by · A replace operation substitutes selected matching content or values with specified alternatives in a string, collection, or other object, either returning a result or modifying the object.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




