I think you must be having fix pattern like first 12 characters denotes XXX then next 6 characters denotes YYY then last 2 characters denotes ZZZ.
If this is the case then you can use the subString method to extract the info from/to particular index.
Do not wait to strike till the iron is hot; but make it hot by striking....
Why would you like a more advanced solution if this simple solution almost works? I'm saying almost because your code will throw an exception if the String is too short. Instead check for the length:
One more improvement is to get rid of these magic numbers:
Saral Saxena wrote:
could we use in this case as I want to explore, please it wil be a great help if you can show me how the above code can be done through regex..!! thanks in advance..!!
A bit of a weird request, but why not?
In your code, replace this line....
with this one....
Thanks a lot , i will follow your advise..!! thanks a lot ...it will be a great help if you could please specify...
the above regular expression is also doing the same thing that earlier I WAS DOING..THOUGH IT IS MORE PERFECT..!! but I am unable to grasp that regular expression could you please explain it that will make more clear..!1thanks in advance..!