Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は文字列を持っています
String S1="Hello@world@today@2018/01/01" S2="Foo@Obj@new@tornado"
これらの各文字列から常に最後のトークンを取得したいと考えています。例: S1 で 2018/01/01、S2 でトルネード。
助けてください。
@ が一般的な区切り文字である場合は、実行できます
String[] parts = S1.split("@"); final String lastItem = parts[parts.length - 1];
または、好みに応じて、おそらくより簡単な方法があります。
final String lastItem = S1.substring(S1.lastIndexOf("@"));