#import int main (int argc, const char * argv[]) {@autoreleasepool {/* nsstring *[email protected] "Apple banana pear";Nsarray *array=[str componentsseparatedbystring:@ ""];NSLog (@ "%@", array); *//*//substringtoindex from the beginning of the string to the location you specified, but not the location you specifiedNSString *[email protected] "ABCDEFG";NSString *newstr1=[str1 Substringtoindex:4];NSLog (@ "%@", NEWSTR1);Substringfromindex all character
Say is the most accurate intercept length, in fact, I am not sure whether it is the most accurate, specific how accurate to see the effect of the following know:String to test first:
The following is an effective illustration of an exact intercept string:
The specific function code is as follows:
Utf-8 Chinese interception, single-byte in
Experienced programmers found that PHP judged the length of the string, using Isset () faster than strlen () and executing more efficiently.That
Copy Code code as follows:
$str = ' aaaaaa ';
if (strlen ($STR) > 6)
Vs
if (!isset ($str {6})
With the example simple test, the situation is basically true, isset () efficiency is almost 3 tim
MySlq creates a fixed-length string primary key. The trigger is used to make the directory's primary key neat and easy to use, so the fixed-length string is used as the primary key. When the table is empty and there is only one data, LAST_INSERT_ID () the value obtained by the method is 1, so the trigger judges drop ta
/** Copyright (c) 2012, School of Computer Science, Yantai University * All Rights Reserved. * file name: test. CPP * Author: Fan Lulu * Completion Date: July 15, December 18, 2012 * version: V1.0 ** input Description: none * Problem description: Evaluate the string length with the pointer and return *ProgramOutput: String
String.Length This allows you to test the length of the string. Oh, this will help you get started with JS friends.
Gets the length instance of a string
A more detailed example.
/' * * * at the front of each line in 4 to the last row (if eee add Eee after each line)
Character test:
= = (or =): Compare, equal to true, unequal to false: [$A = $B]! =: Unequal to True, equal to False >
For loop: Enter condition, exit condition
for variable in list;
Loop body
Done
Generate list; {1..100}
Seq 10:1--10 seq 5 10:5--10 seq2 2 10:2 4 6 8 seq 1 2 10:1 3 5 7 9
SEQ: Start number step
Huawei test-Child string separation and Huawei string SeparationDescription:Input any string sequence through the keyboard. The string may contain multiple substrings separated by spaces. Compile a program to automatically separate the substrings and separate them with comma
Huawei test-Child string separation and Huawei string Separation
Description:Input any string sequence through the keyboard. The string may contain multiple substrings separated by spaces. Compile a program to automatically separate the substrings and separate them with comm
order to see the effect more intuitively, I did some more loops). It is conceivable that this one-step operation consumes me more than a second time, plus other code time consumption, the entire script block execution time is unbearable. Is there any plan to optimize it? Is there any other way? The answer is certainly yes, otherwise I write this article is nonsense.
The quicker way to do this is to use an array, instead of stitching it into a string
string length 1010000 bytes, stitching takes 1044 milliseconds!
Netscape 7.0:
String concatenation method: After stitching the big character string length 1010000 bytes, the stitching takes 10273 milliseconds!Array assignment Join method: After the concatenation of large
Package com.abuge;
Import Java.util.Iterator;
Import Java.util.LinkedHashSet;
Import Org.junit.Test; /** * A string of lowercase letters (A~Z) entered through the keyboard.
Write a string filter that filters out characters that are not the first occurrence if there are multiple identical characters in the string.
For example, the
bit abstract, so use examples to prove it.Static Final intMAX = 100000; Static Finalstring[] arr =NewString[max]; Public Static voidMain (string[] args)throwsException {//random assignment of an integer array of length 10integer[] Sample =NewInteger[10]; Random Random=NewRandom (1000); for(inti = 0; i ) {Sample[i]=Random.nextint (); } //Log program start time Longt =System.currenttimemillis (); /
String.Equals () How to useUsed to compare strings represented by a string of two objects Public class stringequals { Public Static void Main (string[] args) {String s1=New string ("Hello");String s2=New string ("Hello");System. o
1.1 String test operatorThe string test operator has the function of comparing whether two strings are the same, whether the length of a string is zero, whether the string is null (NOTE
This is often asked or tested during an interview or written test.
The prototype for the known class string is:
Class string
{public
:
string (const char *STR = NULL);//Normal constructor
string (const string other); Copy c
/** STD: String Detailed Description * Visual Studio 2008sp1, use Ctrl + F5 to start debugging */# include
Output result
Appending the C-string cstra to string stra gives: Hello C-stringhello C-stringsoinput a character stringlong long ago, there is girl, she's name is Little RedHat .. before line: Long long ago, there is girl, she's name is Little RedHat .. qu
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.