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 →
Algorithms Every Programmer Should Know
A substring is a contiguous non-empty sequence of characters within a string.
- How it is used
- Uses candidate substrings as windows when searching text for a pattern with Rabin–Karp.
- How deep it goes
- Defines substrings and explains their role in hash-based window comparison, including character checks for collisions.
- Examples
- Uses text windows such as ALI and LIC to illustrate hash comparison and one-character window shifts.
- What you can do after
- Apply Rabin–Karp by comparing candidate-window hashes and checking matching windows character by character.
Read how Algorithms Every Programmer Should Know explains substring →
Also covered in
- Statistics Slam Dunk
- Julia as a Second Language
- Grokking Algorithms, Second Edition
- Learn SQL in a Month of Lunches
What to know first
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
- inputAn input is information, a value, or an action supplied to a system, program, or computation for processing or to influence its behavior.
- integerAn integer is a whole-number mathematical value, including negative numbers, zero, and positive numbers, with no fractional part.
- referenceA reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
Related concepts
- replace methodused by · A replace operation substitutes selected matching text or values with specified alternatives, returning a result or modifying the target depending on the API.
- slicingproduced by · Slicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.
- backing arrayuses · A backing array is the underlying array that stores the elements of a resizable sequence or slice.
- 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.
Questions about substring
What is substring?
A substring is a contiguous sequence of characters contained within a larger string or character sequence.
Which Manning books explain substring?
Get Programming: Learn to code with Python, Advanced Algorithms and Data Structures, The Well-Grounded Rubyist, Fourth Edition, Learn C++ by Example, 100 Go Mistakes and How to Avoid Them and Algorithms Every Programmer Should Know.
What should I know before learning substring?
Manning books that teach substring usually introduce string, input, integer and reference first.
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.





