感嘆符の前の単語を削除する方法を教えてください。
たとえば、Sringが
BIM!A , i need only A
SAM!B , i need only B
SNNJ!D , I need only D
感嘆符の前の単語を削除する方法を教えてください。
たとえば、Sringが
BIM!A , i need only A
SAM!B , i need only B
SNNJ!D , I need only D
System.out.println(s.substring(s.indexOf("!") + 1));
で検索を行うことができString
ます
Strings s = "ABD!A";
//This gives you the index of the first !
int i = s.indexOf('!');
//now you can Substring
String after = s.substring(i+1);
System.out.println(str.substring(s.lastIndexOf("!") + 1));
これにより、最後の感嘆符の後にある文字列の一部が印刷されます。「!」がない場合は、文字列全体を出力します。ある