Home > Net >  C # PLC communication return value capture characters
C # PLC communication return value capture characters

Time:05-24

"DT1208:14640 \ r \ nDT1209:11572 \ r \ nDT1210:12336 \ r \ nDT1211:13104 \ r \ nDT1212:12337 \ r \ nDT1213:0 \ r \ nDT1213:0 \ r \ n"}


I just want to get the value of the colon, by intercepting string \ r \ n will change position, and can't read fixed length register may be specified is zero, please the teacher

CodePudding user response:

Preferably in the array, such as
The number [0]=14640
The number [1]=11572
The number [2]=12336
.
The number [3]=0
thank you

CodePudding user response:

Use first \ r \ n divided by an array of strings, each with: segmentation,

CodePudding user response:

 
String text="DT1208:14640 \ r \ nDT1209:11572 \ r \ nDT1210:12336 \ r \ nDT1211:13104 \ r \ nDT1212:12337 \ r \ nDT1213:0 \ r \ nDT1213:0 \ r \ n";
Int [] array=Regex Matches (text, "(? <=\ \ d + (?)=\ \ r \ \ n) "). Cast (). The Select (m=& gt; The Convert. ToInt32 (m. alue)). ToArray ();
  •  Tags:  
  • C#
  • Related