如何根据c#中的任何特殊字符拆分上传的文本文件? [英] how to split uploaded text file based on any special character in c#?

查看:75
本文介绍了如何根据c#中的任何特殊字符拆分上传的文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分割上传的文本文件的源代码基于什么特殊字符?

解决方案

试试这个。



  string  input =   q~c!d#e5; 3'4]%f ^ g& h(; 
char [] specialChars = input.Where(k = > (!( char .IsLetter(k)|| < span class =code-keyword> char .IsDigit(k))))。ToArray();
string [] split = input.Split(specialChars,StringSplitOptions.RemoveEmptyEntries);


Hi Praveen,



存储了上传文件文本字符串然后使用string.splip(/)函数拆分它。



例如



  string  text =    prasad / raghu / praveen; 
string [] splittedValues = text.Split(' / );





splittedValues商店如下



 splittedValues [ 0 ] =   prasad ; 
splittedValues [ 1 ] = raghu ;
splittedValues [ 2 ] = praveen ;


source code for how to split uploaded text file base don any special character?

解决方案

Try this.

string input = "q~c!d#e5;3'4]%f^g&h(";
        char[] specialChars = input.Where(k => (!(char.IsLetter(k) || char.IsDigit(k)))).ToArray();
        string[] split = input.Split(specialChars,  StringSplitOptions.RemoveEmptyEntries);


Hi Praveen,

Stored the uploaded file text in string then split it using string.splip("/") function.

e.g.

string text ="prasad/raghu/praveen";
           string[] splittedValues = text.Split('/');



splittedValues stores as follows

splittedValues[0] = "prasad";
splittedValues[1] = "raghu";
splittedValues[2] = "praveen";


这篇关于如何根据c#中的任何特殊字符拆分上传的文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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