🌐
W3Schools
w3schools.com › jsref › jsref_substring.asp
JavaScript String substring() Method
More examples below. ... The substring() method extracts characters, between two indices (positions), from a string, and returns the substring.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › substring
String.prototype.substring() - JavaScript - MDN Web Docs
The substring() method of String values returns the part of this string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.
Discussions

How do I only replace the first instance of a substring?
Solved. In case you also need it, and you're using regexes: string = string.left(regex_match.get_start()) + (string.right(string.length() - regex_match.get_end())) This basically just adds the string that's to the left of the match to the string that's to the right of it, skipping over it. More on reddit.com
🌐 r/godot
2
1
March 31, 2024
whatIsTheSubstrReplacement
Imagine looking at the doc before calling a function you don't know. More on reddit.com
🌐 r/ProgrammerHumor
203
2473
December 22, 2023
How do you determine string A contains string B?
This is not necessarily a Vue-related question, but rather JavaScript-related one, so I don't see how this post belongs here. You can use String.prototype.includes method. More on reddit.com
🌐 r/vuejs
22
0
December 22, 2023
Why is my JSInterop string.contains() method failing?
Isn't it string.includes() ? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes More on reddit.com
🌐 r/Blazor
2
2
December 13, 2023
🌐
freeCodeCamp
freecodecamp.org › news › javascript-substring-examples-slice-substr-and-substring-methods-in-js
JavaScript Substring Examples - Slice, Substr, and Substring Methods in JS
March 22, 2020 - The substring method expects two parameters: ... Let’s see the usage in an example. Suppose that we have the example string below: const myString = "I am learning JavaScript and it is cool!";
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-substring-method
JavaScript String substring() Method - GeeksforGeeks
For example, you might extract the first name or last name from a full name string. ... let s1 = "Amit Ray"; let s2 = s1.substring(0, 4); let s3 = s1.substring(5); console.log(s2); console.log(s3); You can use substring() to extract parts of ...
Published: January 16, 2026
🌐
TechOnTheNet
techonthenet.com › js › string_substring.php
JavaScript: String substring() method
In this example, we have declared a variable called totn_string that is assigned the string value of 'TechOnTheNet'. We have then invoked the substring() method of the totn_string variable to extract the substring from the string.
🌐
ReqBin
reqbin.com › code › javascript › i5foejaa › javascript-substring-example
How do I get a substring from a string in JavaScript?
August 26, 2026 - To get a substring from a string in JavaScript, you can use the built-in string.substring(start, end) method.
🌐
Programiz
programiz.com › javascript › library › string › substring
Javascript String substring()
if (string.substring(i, i + oldChars.length) == oldChars) { string = string.substring(0, i) + newChars + string.substring(i + oldChars.length, string.length); } } return string; } const string = "Java Tutorials"; let newString = replaceString("Java", "JavaScript", string); console.log(newString); ...
🌐
Tabnine
tabnine.com › home › how to use the substring method in js
How to Use the substring Method in JS - Tabnine
July 25, 2024 - The example below demonstrates how to use the substring() method to retrieve a portion of a string: const str = "Can I have a piece?"; console.log(str.substring(11, 18)); // Expected output: a […]
Find elsewhere
🌐
Edureka
edureka.co › blog › javascript-substring
JavaScript Substring() | How is it different from substr() & slice()? | Edureka
January 9, 2025 - This JavaScript Substrig article will provide in-depth knowledge about the same in the following sequence: ... A substring is a subset of another string. It is a contiguous sequence of characters within a string. For example, “Welcome to Edureka” ...
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript string methods › string.prototype.substring()
JavaScript Substring(): Extract a Substring from a String
November 3, 2024 - The following example uses the substring method to extract a substring starting from the beginning of the string: let str = 'JavaScript Substring'; let substring = str.substring(0,10); console.log(substring);Copy
🌐
Codecademy
codecademy.com › docs › javascript › substring
JavaScript | Substring | Codecademy
May 29, 2025 - This codebyte example uses the .substring() method with the startIndex parameter being greater than endIndex to extract characters from index 0 to index 6 in the str string:
🌐
Mimo
mimo.org › glossary › javascript › substring
JavaScript Substring Method: Learn String Extraction
The substring() method takes two parameters: the start index and the end index (optional). The extraction includes characters from the start index up to, but not including, the end index. ... Become a full-stack developer. Learn HTML, CSS, JavaScript, and React as well as NodeJS, Express, and SQL
🌐
Medium
medium.com › nerd-for-tech › basics-of-javascript-string-substring-method-1083c3d918e2
Basics of Javascript · String · substring() (method) | by Jakub Korch | Medium
June 22, 2021 - First mismatch is when the start position is greater than the end position. In case of the substring() method, two parameters are swapped and used that way. No problem. For the slice() method, this means an empty result. Another example is using negative values.
🌐
Upmostly
upmostly.com › home › tutorials › javascript substring: extracting strings (with examples)
How to Use the Substring Method in Javascript (Code Examples)
October 28, 2021 - const todo1 = "01 - Pick up dry-cleaning"; const todo2 = "02 - Go food shopping"; const todo1Task = todo1.substring(5); const todo2Task = todo2.substring(5); The example above shows how you can return the rest of the string after a specified ...
🌐
Tutorial Gateway
tutorialgateway.org › javascript-substring
JavaScript substring Function
August 7, 2026 - When we use the first argument ... from the beginning of a string. In the example, we use zero and 11 as the starting and ending index positions of the substring() function....
🌐
Bito
bito.ai › home › how to use the javascript substring method
How to Use the JavaScript Substring Method - Bito
October 19, 2023 - If either index is negative or greater than the length of the string, the method treats it as 0. Let’s see an example: const text = "JavaScript is awesome"; const substring = text.substring(10, 5); console.log(substring); // "JavaS"
🌐
Useaxentix
useaxentix.com › blog › javascript › javascript-substring
JavaScript Substring: substring() Method Explained with Examples
5 days ago - 'JavaScript'.substring(4, 3) does not return 3 characters starting at index 4; it swaps the arguments and returns 'a'. To take n characters from start, write substring(start, start + n).
🌐
Refine
refine.dev › home › blog › tutorials › javascript substring method
JavaScript Substring Method | Refine
January 1, 2025 - In this post, we exercised the use of JavaScript substring() with some basic examples. We first learned that substring() is a String extraction method that returns a target portion from a parent string.
🌐
Vultr Docs
docs.vultr.com › javascript › standard library › string › substring()
JavaScript String substring() - Extract Substring Range | Vultr Docs
September 27, 2024 - The script fetches the user's name example by cutting off at the "@" character's index. The substring() method in JavaScript serves as a powerful tool for extracting specified ranges from strings. Its intuitive handling of indices, including adjustments for out-of-bounds values, makes string ...
🌐
TutorialsPoint
tutorialspoint.com › javascript › string_substring.htm
JavaScript String substring() Method
<html><head><title>JavaScript String substring() Method</title></head><body><script> const str = "Hypertext Markup Language"; let indexStart = 5; let indexEnd = 16; document.write("Original string: ", str); document.write("<br>Indices are: ", indexStart, ", ", indexEnd); document.write("<br>Extracted string: ", str.substring(indexStart, indexEnd));</script> </body></html>