在android中拆分字符串

时间:2015-10-09 04:15:04

标签: android string

我正在尝试拆分字符串。例如“城堡”

if (inj == "oui")
{
    Console.WriteLine("Quel est la taille de l'injection? (30 - 50 - 60) ");
    injtaille = Convert.ToInt32(Console.ReadLine());
}
switch (client)
{
    case 1:
       consprix = 25;
       imgradprix = 55;
       analyzeprix = 28;
       switch (injtaille)
       {
           case 30
       }

我希望结果是(1:astle)。相反,我得到(1:城堡) 我希望你们能帮助我。谢谢!

4 个答案:

答案 0 :(得分:2)

使用String[] word = text.split("C");

答案 1 :(得分:0)

简单的说法是'C'与'C'不相同,你使用'c',更好地使用'C',

试试这个

String text = "Castle";
            String[] word = text.split("C");
            Log.d(Constants.RESULT, "1:" + word[word.length-1]);

答案 2 :(得分:0)

使用它:

noriko@NORIKO-VAIO C:\Users\noriko
> heroku --version
Installing Heroku Toolbelt v4... done.
For more information on Toolbelt v4: https://github.com/heroku/heroku-cli
Setting up node-v4.1.2... done
Updating plugins... done
Installing core plugins heroku-cli-addons, heroku-apps, heroku-fork, heroku-git, heroku-local, heroku-run...Error reading plugin heroku-status.         Reinstalling... done
 done
"\x80" on Windows-31J
C:/Program Files (x86)/Heroku/ruby-    1.9.3/lib/ruby/1.9.1/json/common.rb:148:in `encode'
C:/Program Files (x86)/Heroku/ruby-1.9.3/lib/ruby/1.9.1/json/common.rb:148:in `initialize'
C:/Program Files (x86)/Heroku/ruby-1.9.3/lib/ruby/1.9.1/json/common.rb:148:in `new'
C:/Program Files (x86)/Heroku/ruby-1.9.3/lib/ruby/1.9.1/json/common.rb:148:in `parse'
C:/Program Files (x86)/Heroku/lib/heroku/helpers.rb:218:in `json_decode'
C:/Program Files (x86)/Heroku/lib/heroku/jsplugin.rb:82:in `commands_info'
C:/Program Files (x86)/Heroku/lib/heroku/jsplugin.rb:77:in `commands'
C:/Program Files (x86)/Heroku/lib/heroku/jsplugin.rb:204:in `find_command'
C:/Program Files (x86)/Heroku/lib/heroku/jsplugin.rb:12:in `try_takeover'
C:/Program Files (x86)/Heroku/lib/heroku/cli.rb:24:in `start'
C:/Program Files (x86)/Heroku/bin/heroku:29:in `<main>'
Error:       "\x80" on Windows-31J (Encoding::InvalidByteSequenceError)
Command:     heroku --version
Version:     heroku/toolbelt/3.42.16 (i386-mingw32) ruby/1.9.3
More information in C:/Users/noriko/.heroku/error.log

你得到了&#34; astle&#34;从这个

答案 3 :(得分:-2)

使用

    String text = "Castle"; 
    String sub =text.substring(1,text.length); 

    Log.d( "Answer", "1:" + sub);