作者:萌嗒嗒滴妹妹惹人爱i_121 | 来源:互联网 | 2023-05-16 06:34
Forachat-bot,ifsomeonesays!sayitwillrecitewhatyousayafterthespace.Simple.对于聊天机器人
For a chat-bot, if someone says "!say " it will recite what you say after the space. Simple.
对于聊天机器人,如果有人说“!说”,它会在空间后背诵你所说的内容。简单。
Example input:
示例输入:
!say this is a test
Desired output:
期望的输出:
this is a test
The string can be represented as s
for sake of argument. s.Split(' ')
yields an array.
为了论证,字符串可以表示为s。 s.Split('')产生一个数组。
s.Split(' ')[1]
is just the first word after the space, any ideas on completely dividing and getting all words after the first space?
s.Split('')[1]只是空间之后的第一个单词,是否有关于在第一个空格之后完全划分和获取所有单词的任何想法?
I've tried something along the lines of this:
我尝试过这样的事情:
s.Split(' ');
for (int i = 0; i > s.Length; i++)
{
if (s[i] == "!say")
{
s[i] = "";
}
}
The input being:
输入是:
!say this is a test
The output:
输出:
!say
Which is obviously not what I wanted :p
这显然不是我想要的:p
(I know there are several answers to this question, but none written in C# from where I searched.)
(我知道这个问题有几个答案,但没有一个用C#从我搜索的地方写的。)
4 个解决方案