Text UtilitiesLesson 108Free preview
Extract a Substring
This lesson is part of Web Developer Tools · All levels
Summary
A substring is a piece of text taken from a particular position in a string. You can take it based on the initial and the long index, or between two markers like parentheses. In many languages, the index starts from zero and the end-limit is not taken. Understanding this rule prevents the result of one character sliding.
Key points
- Character indexes generally start from 0
- Takes characters until before the end
- Substring exchanges an argument if the start is larger than the end
- The negative index on the slice is calculated from the end of the string
- For text between markers, find the beginning and end positions first
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.