473,387 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

help with storing characters in a string on an interval?

what I want to do is dump the characters in a string into a new string based on an interval say I have a

String blah = "asksa123sbjdskc";

all i want is abc (ie every fifth character)

this is my attempt with 236 characters of junk inbetween the chars i want.

Expand|Select|Wrap|Line Numbers
  1. String input = "j4o8xcntu2q2o43d0xg9s3ubt5dwxm0llha8acnr6gyw54i9h7e4ay6117kalgygrkm50bg4r7v97d4h9yp4kmyh0dmc6q3t9g2xi1pnpmbfkvs5xa867t7whj3kecqboeukvc0cn9ayfl780gg41y16f90gh12xbuamb1q8bh85p4wijjb1jjkm421oyorueig9gvnwcigngg4sf8nplmp3gtdjjrixyp3eou677jwqefbiemohmfxe0sw3gh6axr4qcopauf7xc25dmmx4yv1x0jxq2517sag288rlt7aqpk2tvccoxsgsmic66rye8eso7fxlh1nl5egnu99ydrrdb6ojafodewxqiw08dqfn0v7wrh8bl67anart7cld2jve1i6lxqfy02y78l00e9tqsse4xit7w4tvw3t6tjwknyv13a9nio68byyosbd5ywbgkjnw1ihw8w8alh845akd5rpuyuno8ljjyvbtyns9oj6r7vkrbowf7qabvk7cndo2cnskapndpcxvgk2io0s1gp2genwxmgcjkcc0v9vl4wgahtdkknv9egoqd9uj97b3sx71xsmcrlct5cu20fl0l5icpc8ttuufrbyuguct15cmgv48sat94364hcj47ojndj4ayq0iqn7dw2kqpe4722fkp297p7m3loxoqwotact0l0b3yg7k25c95rjkxsacnpufwt4a377le0r1f49jfbmla6n9v6jdvdpvmt1imo17qnmjkwlj0qf85egbrm4fdsfawka2dsqdkjv44o8ksdbat2d4nfaps5t9v8f7fgs4j4kf7seg61w62u6c6ectju53xh9j2w44b7wlye6br9ivx4j1hgw8n254u8lywkxcjkiftiheoecrqywv2y1al7ebfa3tdu918c54j65ce857w55pmhfc4v858e5mbc4pg4njts43nbetsiks6is6991glonnk4dot2o61yb5eehfxpjjyx694xaqk9v8nnl14tsik36n823g4k5o0sqxyfl0f5lcw01fpugrd4rqhead06l6wrara892wuvbys81831e8fajrhc7gwbouc9b6brp7huoklnf690bqmsqm3jm23v3mexw6dkv5q1uwojtmsu9uibkgme8jobyrwxo4ld32paxjpoa1h3l793ru95yqhrot8y1xfe72dkrw4dp6iql504yvxd7usb9d4vvkgmjvsicu1cl06obf5wc055c3coqdpsn260n1r7vrfe6fr420ga2f6iq2ckkypa3a5k9xu6e8g0bilwk99rnt7da4shv6tej1pqennpqosry9qm0a9g0mcwi3wsjwjxshcfms1u7nconeacdyglwhga9ekb7f3sexhacr8osh948b7qkklo96wm08r1jwrr2ybfe9mta4h5aoh3hcbop5n0364mc1fijfo1d4vi909oyiubsoaqnkha7xhi7i1mt1ab1977ebn7h3nkaiqxa09es0uari4qwksw5ltbc4wtsbfe5fdt1kkwmu138d79ecal1c3hck2m2nb3bu21f5ynp5g3uynq41yg98f3q9y78cixahtwg1g4mc4o9gyqclx7wipctbga1p5jtnyodlx5brgr3b5tdntvyh4sc64x616i4hhrqd3vyslljqt8v4rwvuytnr72lrdrc2sr9m8gejdu6fgak5dg1d9mwaryp1vqlyjlu40r9qpi1lrm7wj63vdu8qnoh65dabd4r35l6y3r2el1n7h6ej9mb1flpqwejvij78s0e76ydh7irwrss3jdnfcmau4ci4vjra2u8u3456w6rw75vmef4me9g31xhnffdhfy9a7koqyd6dtgern1ajj2o9m1dcr57fotbe05vwm4m810xw28jlsa2ppfe831s71sc6k77sqdmet45qkqw43iulrd8bguaeo8w1ub8ipneq02l6ree63fkge2k5309w0gtqa5l80j8q6ewuo3hngy91241vlm8v9ospothr0xjd0ihk8v3849ir30v3sg4vnyvsfy528s9ox6e0vl2wpge2ytbispseiddhp1e1etgg84s4mnt2lrgo6rxctf4mlgddx1drm5pua6ihvag9lr3oxai8h091n765wcggx5hbkxfpx3urrkvb6ky4fe40nsr6exfnbyi3wbp5l9ks7qafqwd7uferfl415m5xn3c4nsc90taj7lu8xwdb3fc6cu5vwph0uqe0f53tkspylvhewohsbjlgaon0pf2dexga45fs77t3suo1hnmo9q2h04cio06isd2xt30bdldh9vbmf0264b2nm83nenfdmdygl1dw51v3i9l1vbh1qamojtdy96c5dkb2t7s0aq4r013i05mqd0d6th1409e97t5f11ieu4jprqpalpj9of4bancmyv9fcn8lpffr0yi9xl76afo4734wuixy1fxleed9wbom9wqtka7ht1c87vpk0f6dgc8kqg6yfurqxwmochrytxksxru5tt83d264jol73hthvwhgo4ya7671pj4mnha9ew26r4pub9g8iuaqax4r6oe10m38l1kcy9hatpwm9eo66riysvdpkar930dyrls4jf7w99j3xqv45nccjqpgtsvt2gbh8ix8kqy62q790orh0ygu8raldcld2qxtpjlsoe5fx9ad4t7f3h8vs37bdotkgxj6gylawasc1ofeak29u45qy71neyeg3ib6628dl7vkqidly5sf00ifeu3fsys8m2uuq78p5e3ayq97bydsj64x96nm9s1he8so2e6t4bn519b28chjfo70paiyeo0m75oy2up1jatph87st89ay8ymsxtyh251olt4c31vcfgnngry82pxt28aa44qrech1cy5sno45tyxt48kowvurvftgx5h7nnvq311k2dndga1pb4e3l0s2y6lw859fol11bdyon4j56fjtao7ub1jkl3qyqec86xmviwgf8cnu81qw0pt990jy4fqhgxhhw001osg7f1yt4pdm6ii1x8072s2hr14hcay43j9pu5nee6hbd3l484q8aq62pcfxi9fb605a9ycs67xmbfnbs7y36xc6gt7tkx92a3p99ju4eh2ia5fyxq6p1tbdq2mveg2dku8k89o0x3eix9jaotioqb7vnffrt5dgb9i0tk2w3fmqvfc35ny8jd823l8cchpvgnlk7r2x0198suu1hcfp403kga9ho1r1b44qjekgxvyfvugucp0ipweu0fb45tpueq5s2theca8viu1r9d9xo3muxnxmmwuqurg9fw22ekq372d1xk10m6w2tfsygb0hfcxpqpynfcd8c6m3gi25x274o3s5vfpy5nq0e0imm3df048phffrva2v9c1168r6rtwpy5gkasq09jv8kflmy8214sdfuch03ohfji4m739ps6q4960ooitmhs5lf9pc57l0snka98vsu7sf0yh4vuqqbbr416q5tam6y4y87x6dskhjb09elguqv43roynoknm8f13hov1y6";
  2. String local = "";
  3. for (int i =0; i < input.length(); i = i + 236)
  4. {
  5.                         if ((i+236)>=0 && (i+236)<input.length())
  6.             {
  7.                 local = local + input.charAt(i + 236);
  8.             }
  9. }
  10.  
but I'm not getting what i should be.
thanks for any help or insights
Apr 5 '10 #1
2 1646
jkmyoung
2,057 Expert 2GB
Your code is starting on character 0, not 235.
Apr 5 '10 #2
Yea, i managed to get it working. albeit convoluted. but thanks =)
Apr 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Daniel | last post by:
I'm trying to make a site work for japanese characters. It works fine except for the alerts in javascript. The characters are stored in unicode, as this; 'コミック全巻配' Those unicode characters...
5
by: yoelgold | last post by:
hi can someone please tell me what "document.MM_sr" is. I tried searching for a explanation on the web but cant find anything. What does MM_sr represent? and where can i get documentation on it. ...
40
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. ...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
14
by: WENDUM Denis 47.76.11 (agent) | last post by:
While testing recursive algoritms dealing with generic lists I stumbled on infinite loops which were triggered by the fact that (at least for my version of Pyton) characters contain themselves.See...
1
by: romiko2000 | last post by:
Hi Folks, I got a weird problem, I create an XMLWriter to post a document via the webrequest stream and after running a network trace, I notice the data is prefixed with 3 invalid characters! ...
8
by: machikelxol | last post by:
I'm having a strange error when I try reading from a file. here is the code: buffstring values = 1, 2, 3, 4 and then it crashes afterwards on the 4th iteration. This works fine until the fourth...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
12
by: StephQ | last post by:
I face the following problem. I wrote a poor's man plotting function: computePlot. This function append some x-values belonging to step and the correseponding f( x ) (for a given const member...
10
by: CuTe_Engineer | last post by:
hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.