如何使用C#从字符串中子字符串化 [英] how to substring from a string using c#

查看:76
本文介绍了如何使用C#从字符串中子字符串化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是一行巨大的.txt文件,我正在逐行阅读.我需要第二列的值.在这一行中,我需要提取"C9006".

The following is a line of huge .txt file and i am reading it line by line. I need the value of second column. In this line, I need to extract 'C9006'.

ABC先生| C9006 |白场,ON | 493-493-4939 | 493-493-4939 | YR |无效

Mr ABC|C9006|The white field, ON|493-493-4939|493-493-4939|YR|Inactive

注意:定界符char是管道符号'|'.第二列的长度不一致.

Note : The delimiter char is pipe sign '|'. The length of second column is not consistent.

请帮助.

推荐答案

String value = "A|B|C";
String secondColumn = value.split("|")[1];

这篇关于如何使用C#从字符串中子字符串化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆