Home > Net >  C # how to intercept a certain length of string specifies the beginning and end
C # how to intercept a certain length of string specifies the beginning and end

Time:10-08

[color=# FF0000
If inscribe
R230101N, Nest Sheet 1122 0244 0,18,18 mm fraxinus mandshurica, 0,1,1, F, 0,
R230201N, Nest Sheet 2121, 9.2, 2438.4, 9, 9 mm fraxinus mandshurica, 0,1,1, F, 0,
R23b0004, roof (TO), 457.2, 421.2, northeast China ash, 18, 19 mm 1,1,1, B, 0
R23b0005, backplane (DE), 457.2, 421.2, northeast China ash, 18, 19 mm 1,1,1, B, 0
R23b0006, former pedal (FT), 90421.2, northeast China ash, 18, 19 mm 1,1,1, B, 0
R23b0007, after the pedal (BT), 90421.2, northeast China ash, 18, 19 mm 1,1,1, B, 0
Like the character above is through the TXT file open my idea is on the extraction of specified at the beginning of the "r" (lowercase), end ", "such as" r23b0004 "and then continue to intercept, access to a few Numbers shown in label1, save to the database after capture, then contrast and text box is the same (the contents of a text box input enter in contrast, does not need the button control), such as label1 number minus one, not the same as the pop-up warning, until label1 is 0,

] [/color]

CodePudding user response:

With regular expressions

CodePudding user response:

reference 1/f, 711 glaciers response:
with regular expressions

Is no just ask

CodePudding user response:

Roc
reference 2/f, Chen reply:
Quote: reference 1/f, 711 glaciers response:

With a regular expression

Is no just ask


Search for c # regular expressions, have a look at will,

CodePudding user response:

reference 3 floor 711 glaciers response:
Quote: refer to the second floor Roc, Chen reply:

Quote: reference 1/f, 711 glaciers response:

With a regular expression

Is no just ask


Search c # regular expressions, it will use the

String STR=streamReader. ReadToEnd ();
The Regex reg=new Regex (" [r] [^ \ \] + ");

Foreach (Match m in reg Matches (STR))
{
TextBox1. Text=m. alue.
}
Now write but can only extract the last: what happened

CodePudding user response:

There are two methods available, firstly use
 
Var dd="". The Split (', '). The Where (a=& gt; A.C ontains (" r ")). ToArray ();
String triple="";
Var aa=aaa. The Substring (0, aaa. IndexOf () ", ");

CodePudding user response:

@ "r [^,] + (?=), "

CodePudding user response:

String s=Regex. Match (" R230101N, Nest Sheet 1122 0244 0,18,18 mm fraxinus mandshurica, 0,1,1, F, 0, ", "[Rr] [^ \ \] +"). The Value;
Can also
String s="R230101N, Nest Sheet 1122 0244 0,18,18 mm fraxinus mandshurica, 0,1,1, F, 0,";
The string result=s.S plit [0] (', ');

CodePudding user response:

reference Roc, 4/f, Chen reply:
Quote: refer to the third floor 711 glaciers response:

Quote: refer to the second floor Roc, Chen reply:

Quote: reference 1/f, 711 glaciers response:

With a regular expression

Is no just ask


Search c # regular expressions, it will use the

String STR=streamReader. ReadToEnd ();
The Regex reg=new Regex (" [r] [^ \ \] + ");

Foreach (Match m in reg Matches (STR))
{
TextBox1. Text=m. alue.
}
Now write but can only extract the last how make


A novice?

The foreach loop, textBox1. The Text has been assignment again, until the last time,
You can change:
 string STR=streamReader. ReadToEnd (); 
The Regex reg=new Regex (" [r] [^ \ \] + ");
The StringBuilder sbT=new StringBuilder ();
Foreach (Match m in reg Matches (STR))
SbT. AppendLine (m. alue);
TextBox1. Text=sbT. ToString ();

Of course, your textBox1 multiLine property to true,

CodePudding user response:

refer to the eighth floor wid999 response:
Quote: reference Roc, 4/f, Chen reply:

Quote: refer to the third floor 711 glaciers response:

Quote: refer to the second floor Roc, Chen reply:

Quote: reference 1/f, 711 glaciers response:

With a regular expression

Is no just ask


Search c # regular expressions, it will use the

String STR=streamReader. ReadToEnd ();
The Regex reg=new Regex (" [r] [^ \ \] + ");

Foreach (Match m in reg Matches (STR))
{
TextBox1. Text=m. alue.
}
Now write but can only extract the last how make


A novice?

nullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related