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
Used in today's project to remove the last character in the string
Original string 1, 2, 3, 4, 5, 6,
Remove the last character "," and the final result is 1, 2, 3, 4, 5, 6.
The Code is as follows:
$ STR = "1, 2, 3, 4, 5, 6 ,";
$ Newstr = substr
The substr () function returns part of the string.SyntaxSubstr (string, start, length)Example 1 The code is as follows:Copy code Echo substr ("Hello world! ", 6 );?>Output:World! Example 2 The code is as follows:Copy code Echo substr
Grammar
The code is as follows
Copy Code
substr (String, start_position, [length])
The string is the source string.
Start_position is the location of the extraction. The first position in the string is always 1
This article introduces the use of substr () string intercepting function in SQL, which is very simple and practical, and can be consulted by students in need.
The substr (string, 1, 3) function reads: A string that takes a 3 word length from the
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
Oracle's use of the SUBSTR functionGets a string that specifies the starting position and length of the string substr (string, start_position,[length] )Such as:SUBSTR ('This is a test', 6, 2) wouldreturn ' is'SUBSTR ('This is a test', 6) wouldreturn
The substr (string, 1, 3) function reads: A string that takes a 3 word length from the left to the right.
The result: Str
From right to left?
There should be another function to provide such a function!
In fact, from right to left this function
has been used substr () to intercept a part of the string, although know that there are SUBSTRB (), but did not use, also do not understand where to use them, today just test the two functions, do some summary:
Let's start by introducing the two
oracle| function
In Oracle/plsql, the SUBSTR functions allows you to extract a substring a string.The syntax for the SUBSTR function is:substr (String, start_position, [length])
DescriptionThe string is the source string.Start_position is the
SUBSTR (string, intercept start position, intercept length)//return intercepted wordsubstr (' Hello World ', 0, 1)//return result is ' H ' * start with a string of length 1 from the first charactersubstr (' Hello World ', 1, 1)//Returns the result
Transfer required:EXISTS specifies a subquery to detect the presence of a row. Syntax: EXISTS subqueryParameter: subquery is a restricted SELECT statement (the COMPUTE clause and the INTO keyword are not allowed).Result type: Boolean returns TRUE if
Used in today's project to remove the last character in a string
The original string 1,2,3,4,5,6,
Remove the last character "," and the end result is 1,2,3,4,5,6
The code is as follows:
The code is as follows:
$str = "1,2,3,4,5,6,";
$newstr =
Oracle:
Syntax:
Substr (string, a, B ):
A: Starting from the nth digit, the first digit a = 1,Last Third digit (right in sqlserver) a =-3
B: Several Characters[SQL]
Substr ('This is a Test', 6, 2) wowouldReturn 'Is'
Substr ('This is a Test', 6)
Differences between strlen, mb_strlen, substr (), mb_substr () and mb_strcut in php. This article describes in detail the differences and usage of strlen, mb_strlen, substr (), mb_substr (), and mb_strcut. For more information, see. About the use of
This example describes the use of SUBSTR function string interception in PHP. Share to everyone for your reference, as follows:
The SUBSTR function in PHP is defined as follows:
SUBSTR (String,start,length)
The parameters are described as
SUBSTR
The substr () function Chinese version of the normal substr () function can get a string of a specified length substring, but encountered in Chinese can be garbled at the end of a new string, the following function will be more than $len
Php intercepts Chinese strings and garbled characters. This was recently discovered. I have previously written an article about automatic generation of meta information.That article describes how many words are used as the description method before
We know that sometimes use substr to intercept the Chinese character string of the UTF-8, there will often be garbled, why is such a problem, this article tells you the answer.Take a look at this piece of code (character encoding for UTF-8 ):Copy
Used today in the project to remove the last character in the stringThe original string 1,2,3,4,5,6,Remove the last character "," and the end result is 1,2,3,4,5,6The code is as follows:The code is as follows:
$str = "1,2,3,4,5,6,";
$newstr =
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.