Split Java String -
title seems simple. don't idea. situation
i have string in java program
string scz="3282e81wht-22/24"; i want split above string 3 strings, such
first string value should 3282e81,
next string should wht(ie, string part of above string , this part of 3 characters ),
next string value should 22/24 (which occur after -)
in short
string first= /* expression on scz , value should "3282e81" */; string second= /* expression on scz , value should "wht" */; string third= /* expression on scz , value should "22/24" */; input can like
scz="324p25blk-12"; so 324p25 first string, blk second (of 3 characters). 12 third ( after - symbol )
how solve this?
if string's second part (wht) etc of 3 characters following code surely you
string scz = "3282e81wht-22/24"; string third[] = scz.split("-"); string rev = new stringbuilder(third[0]).reverse().tostring(); string second=rev.substring(0,3); string first=rev.substring(3,rev.length()); // here reverse string original first=new stringbuilder(first).reverse().tostring(); second=new stringbuilder(second).reverse().tostring(); system.out.println(first + " " + second + " " + third[1]);
Comments
Post a Comment