of the global RegExp object are updated to reflect the matching result. The array returned by the match function in JavaScript has three attributes: input, index, and lastIndex. The Input attribute contains the entire searched string. The Index attribute contains the position of the matched substring in the entire searched string. The LastIndex attribute contains the next position of the last character in the last match. If the global sign (g) is not set, the 0 element of the array contains the
last character in the last match. If the global flag (g) is not set, the 0 element of the array contains the entire match, and the 1th to n element contains the any sub-match that has occurred in the match. This is equivalent to an Exec method that does not have a global flag set. If the global flag is set, elements 0 through n contain all matches.The following example shows the use of the Match function method in JS:function Matchdemo () {var r, re; Declares a variable.var s = "The rain in
70 : 47 ! No one ever imagined that the world championship finals would be such a big gap, and it was in Spain's absence of the No. 1 player Gasol!
I asked myself when I watched the Greek team make a shot and asked myself: this is to make the German team only get a match47Point: Win the Chinese team31The Greek team? In just ten days, what makes this team so vulnerable?
The only answer we can get is psychology. After winning the United States, the Greek team made preparations to celebrate
There are n PL sisters, and the first word in each line is the nationality of the sister, followed by the sister's name.
Your task is to count the number of Sisters of the same nationality, and then output in alphabetical order.
First, I read all the nationalities and then sorted them alphabetically by qsort.
List of conquestsInput:Standard InputOutput:Standard outputTime limit:2 seconds
In Act I, Leporello is telling Donna elviraabout his master's long list of conquests:
''This is the list of
Problem BList of conquestsInput:Standard InputOutput:Standard outputTime limit:2 seconds
In Act I, Leporello is telling Donna Elvira about his master's long list of conquests:
''This is the list of the beauties my master has loved, a list I 've made out myself: Take a look, read it with me. in Italy six hundred and forty, in Germany two hundred and thirty-one, a hundred in France, ninety-one in Turkey; but in Spain already a thousandAnd three! Among t
Substr method
Returns a substring of the specified length starting at the specified position.Stringvar.substr (start [, length])ParametersStringvarRequired option. The string literal or string object to extract the substring.StartRequired option. The starting position of the desired substring. The index of the first character in the string is 0.LengthOptions available. The number of characters that should be included in the returned substring.DescriptionIf length is 0 or negative, an empty stri
array of elements, and can also be arranged alphabetically by number size. Listing B shows us an example of it:
Listing B
Copy Code code as follows:
?>
Its output results are as follows:
Copy Code code as follows:
Array ([0] => 8
[1] => 7
[2] => 5
[3] => 2
[4] => 1
)
Sort by keyword
When we use arrays, we often reorder them according to the array of keywords, from high to low. The Ksort () function is the sort of function that is sorted
found to return an array and the properties of the global RegExp object are updated to reflect the result of the match. The match function method in JavaScript returns an array with three properties: input, index, and lastindex. The Input property contains the entire lookup string. The Index property contains the position of the substring that matches the entire lookup string. The Lastindex property contains the next position of the last character in the last match. If the global flag (g) is no
The difference between the substr method and the substring method used by JS to intercept the string. If you need it, you can select it as needed.
Substr Method
Returns a substring of the specified length starting from the specified position.
Stringvar. substr (start [, length])
Parameters
Stringvar
Required. The String text or String object to extract the substring.
Start
Required. The starting position of the required substring. The index of the first character in the string is 0.
Length
Opti
If the length is 0 or negative, an empty string is returned. If this parameter is not specified, the substring will continue to the end of stringvar. Differences between the substr method and the substring method of JS string Truncation
Returns a substring of the specified length starting from the specified position.
Stringvar. substr (start [, length])Parameters
Stringvar
Required. The String text or String object to extract the substring.
Start
Required. The starting position of the required s
One of Beijing's 80-plus stories about the poor travel of xiaomingniu in Europe, sleeping at the airport, cooking on your own, and traveling to Portugal and Spain for over 20 days. Only then can we find that poor games are happy. In other words, traveling is to get lost and to meet beautiful people. The Prose Written in beidao in The Book of failure is not expected to be high. Due to political reasons
One of Beijing's 80-plus stories about the poor t
that appears from the right to the left (opposite to indexOf)
Function: returns the string index value.
Example:
Var src = "images/off_1.png"; alert (src. lastIndexOf ('/'); alert (src. lastIndexOf ('G'); // the pop-up values are: 6, 15
Supplement: differences between substr and substring Methods
Substr Method
Returns a substring of the specified length starting from the specified position.
Stringvar. substr (start [, length])
Parameters
Stringvar
Required. The String text or String object to
Today, douniu was defeated by the French team with a score of. At that time, he did not finish the opening report. When I know the score, I am very depressed. I like Spain because of Raul. During the match with France, it happened to be raer's birthday. He started the game, but unfortunately he didn't even try it! Is he really old? The golden boy who scored the goal in that year was no longer available. People will grow old one day, new people will ap
Croatia
F
Berlin
11
Spain vs Ukraine
H
Laibixi
15
June 15Thursday
00: 00
Tunisia vs Saudi Arabia
H
Munich
16
Germany vs Poland
A
Dortmond
17
Ecuador Vs Costa Rica
A
Hamburg
18
June 16Friday
00: 00
England vs Trinidad and Tobago
B
Nuremberg
19
Sweden vs Paraguay
B
Berlin
20
Argentina vs se
C
SUBSTR and substring are both JS intercept string functions, the two uses are very similar, the following is the syntax of the two examples:Substr methodReturns a substring of the specified length starting at the specified position.Stringvar.substr (start [, length])ParametersStringvarRequired option. The string literal or string object to extract the substring from.StartRequired option. The starting position of the desired substring. The index of the first character in the string is 0.LengthOpt
The substr method returns a substring of the specified length starting from the specified position. The stringvar. substr (start [, length]) parameter is required. The String text or String object to extract the substring. Start is required. The starting position of the required substring. The index of the first character in the string is 0. Length is optional. The number of characters to be included in the returned substring. If the length is 0 or negative, an empty string is returned. If this
Differences between JavaScript substr () and substring () Methods
Substr MethodReturns a substring of the specified length starting from the specified position.
Stringvar. substr (start [, length])
ParametersStringvar
Required. The String text or String object to extract the substring.
Start
Required. The starting position of the required substring. The index of the first character in the string is 0.
Length
Optional. The number of characters to be included in the returned substring.
Description
Substr Method
Returns a substring of the specified length starting from the specified position.
Stringvar. substr (start [, length])
Parameters
Stringvar
Required. The string text or string object to extract the substring.
Start
Required. The starting position of the required substring. The index of the first character in the string is 0.
Length
Optional. The number of characters to be included in the returned substring.
Description
If the length is 0 or negative, an empty string is returned.
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.