replace string
Hi All,
I have one String
str1 = "123 678 8910";
I have another String
str2 = "000 111 0000 0000";
I am looking for the way and if possible sample code to replace value of str2 with str1 based on byte position.
How can I replace value of postion 2-5 from str1 with value of 3-6 from str2.
> I dont want to use substring, is there any other best
> approach as this is just a sample my string is huge
As you want to replace sections based on their index position I can't think of any way other than substring()... otherwise you could use replace() and replaceAll(). But they will just replace specific instances wherever they are in the string and not just at specific locations.
> my record is huge and I have to do lot of mapping, so
> was looking for some like collection or similar if
> possible to use and replace based on byte position
How is that drastically different than using StringBuilder.replace() and String.substring()?
~
> > my record is huge and I have to do lot of
> mapping, so
> > was looking for some like collection or similar if
> > possible to use and replace based on byte
> position
>
> How is that drastically different than using
> StringBuilder.replace() and String.substring()?
>
> ~
<some mumblings about efficiency here> ?