Home > Net >  C # to intercept string problem
C # to intercept string problem

Time:10-08

- - the chaoyang district of Beijing, China - chaowai street

I want to how to intercept the chaoyang district in Beijing or the card in the middle of the data?

- can be used as a condition

CodePudding user response:

String STR="- - the chaoyang district of Beijing, China - chaowai street".
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
String strEnd=STR. The Substring (STR. LastIndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);

CodePudding user response:

CodePudding user response:

reference 1st floor ManBOyyy response:
string STR="- - the chaoyang district of Beijing, China - chaowai street".
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
String strEnd=STR. The Substring (STR. LastIndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);


As long as one of them

CodePudding user response:

The split

CodePudding user response:

The split four ignore him

CodePudding user response:

reference SSS_Sans reply: 3/f
Quote: refer to 1st floor ManBOyyy response:

String STR="- - the chaoyang district of Beijing, China - chaowai street".
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
String strEnd=STR. The Substring (STR. LastIndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);


As long as one of the

Is not same as
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
The string strEnd=STR. The Substring (STR. IndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);
STR=STR;//get the Beijing

STR=STR. The Substring (STR) IndexOf (" - ") + 1);
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
String strEnd=STR. The Substring (STR. LastIndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);////get the chaoyang district

CodePudding user response:

With the Substring interception from which one begins to cut total cut how many the latter with the split up, take corresponding according to subscript

CodePudding user response:

Strign s="- - the chaoyang district of Beijing, China - chaowai street", "
String [] sarry=s.s plit (s, '-');

Sarry [0] is
ChinaSarry [1] is the
Sarry [2] is chaoyang district
Sarry [3] is chaowai street

Which use which then want

CodePudding user response:

Strign s="- - the chaoyang district of Beijing, China - chaowai street", "
String [] sarry=s.s plit (s, '-');

CodePudding user response:

String [] sarry=s.s plit (s, '-');

CodePudding user response:

reference 5 floor angel6709 reply:
split four ignored him
width to

CodePudding user response:

Using the Split () method for the ah

CodePudding user response:

2 building to give standard answer...

CodePudding user response:

reference 1st floor ManBOyyy response:
string STR="- - the chaoyang district of Beijing, China - chaowai street".
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
String strEnd=STR. The Substring (STR. LastIndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);


Used the split, but this is the answer

CodePudding user response:

Strign s="- - the chaoyang district of Beijing, China - chaowai street", "
String [] sarry=s.s plit (s, '-');

CodePudding user response:

 string s="- - the chaoyang district of Beijing, China - chaowai street", "
String [] sarry=s.s plit (s, '-');

Sarry [0] is
ChinaSarry [1] is the
Sarry [2] is chaoyang district
Sarry [3] is chaowai street

CodePudding user response:

String [] sarry=s.s plit (s, '-');

CodePudding user response:

REelace (string, string) intercept in current real column all the specified string

CodePudding user response:

The split is one of the most simple way to directly extract as an array, and then through the subscript get what you want

CodePudding user response:

String STR="- - the chaoyang district of Beijing, China - chaowai street".
STR=STR. The Substring (STR) IndexOf (" - ") + 1);
String strEnd=STR. The Substring (STR. LastIndexOf (" - "));
STR=STR. The Substring (0, STR. Length - strEnd. Length);

CodePudding user response:

A regular thing. (? <=-) [/w]? [/w] (?=-)
  •  Tags:  
  • C#
  • Related