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
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
Header file and namespace ::
# Include
Using namespace STD;
Use the subscript type for traversal:
String: The size_type type describes the type of the string type lower mark. So the method for traversing the string type is:
For (string: size_type I
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
${#string}Returns the length of the $string
${string:position}In $string, start extracting substrings from the $position position
${string:position:length}In $string, the $length-length substring is extracted from the $position
This article mainly introduces details about how to use substr, substring, indexOf, lastIndexOf, split, and replace in js. For more information, see indexOf () returns the position of the first occurrence of a specified string value.
The
This article mainly introduces details about how to use substr, substring, indexOf, lastIndexOf, split, and replace in js. For more information, see indexOf () returns the position of the first occurrence of a specified string value.
The
The IndexOf () method returns the location of the first occurrence of a specified string value in a string.
The LastIndexOf () method returns the last occurrence of a specified string value, which is searched forward at the specified position in a
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
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.