如何在第六个空格处分割字符串 [英] How to split a string at sixth white space

查看:95
本文介绍了如何在第六个空格处分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要在第六个空格处分割一个字符串并将分割的部分存储到两个变量中。如何做到这一点。任何帮助都将非常感激。



我尝试了什么:



Hi all,
I need to split a string at sixth white space and store the splitted parts into two variables.How to do this.Any help will be really appreciated.

What I have tried:

Suppose the string is "Two Thousand Four Hundred Ninety Three Dirhams and Twenty Eight Fils " I need to split it at 6 th white space and store first and second splitted parts to two variables

推荐答案

Quote:

如何做到这一点。非常感谢任何帮助。

How to do this.Any help will be really appreciated.



没有魔法工具可以检测你想要的任何条件,你必须建立一个算法来做到这一点。

C#允许你检查任何给定的字符串对空格的字符,你必须设置一个能够检测空间的算法,计算它们并给你第六个位置。



我们不做你的HomeWork。

HomeWork不是设置测试你的技能,乞求其他人做你的工作,它会让你思考,并帮助你的老师检查你对你所采取的课程的理解,以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到某个特定问题,请显示您的代码并解释这个确切的问题,我们可能会提供帮助。


There is no magic tool that will detect any condition you want, you have to build an algorithm to do this.
C# allow you to check any given char of a string against space, you have to device an algorithm that will detect a space, count them and give you the position of sixth.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.


我们不做您的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



所以首先要看一个正则表达式(搜索对于正则表达式c#)并获取 Expresso 的副本[ ^ ] - 它是免费的,它会检查并生成正则表达式,或者查看字符串处理函数:string.Split,string .IndexOf和string.Substring方法。



亲自试试,你可能会发现它并不像你想象的那么难!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

So start by looking at either a Regex (Search for "Regular Expressions c#") and get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions, or look at the string handling functions: string.Split, string.IndexOf, and string.Substring methods.

Try it yourself, you may find it is not as difficult as you think!


这篇关于如何在第六个空格处分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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