In js, both substring and substr are used to intercept strings. What is the specific difference between substring and substr? Is there any difference, next, I will introduce some examples to introduce these problems. Both the substr function and the
Both the substr function and the substring function are used to extract the "substring" from a "parent string. However, there are some differences in usage.
Substr Method
Definition and usage
The substr method returns a substring of the specified
In js, both substring and substr are used to intercept strings. What is the specific difference between substring and substr? Is there any difference, next, I will introduce some instances to introduce these problems.
Substring Method
The substring
Document directory
JavaScript indexOf () method
JavaScript substring () method
JavaScript split () method
JavaScript replace () method
JavaScript indexOf () method definition and usage
The indexOf () method returns the position of the first
Both the SUBSTR function and the SUBSTRING function are functions used to extract a "substring" from a "parent string". But the usage is somewhat different, the following is introduced separately
substr Method
Definitions and usage
The Substr
Use of substring and substr in JS, jssubstringsubstr
The substring method is used to extract characters that are intermediary between two specified subscripts.
Substring (start, end)
Start and end locations, index javascript from scratch
Parameter
1. substring Method
Definition and usage
The substring method is used to extract characters of a string between two specified subscripts.
Syntax
Stringobject. substring (start, stop)
Parameter descriptionStart is required. A non-negative
The substr () method extracts a specified number of characters starting with the start subscript from a string.
StringObject. substr (start, length); start is required. length is optional.
Start is the subscript of the starting position of the
The substr () method extracts a specified number of characters starting with the start subscript from a string.StringObject. substr (start, length); start is required. length is optional.
Start is the subscript of the starting position of the
Common string truncation functions in js include substring substr split slice. The following describes how to use these character truncation functions.
Use substring ()
Definition and usageThe substring method is used to extract characters of a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.