-
Feb 27th, 2021, 11:54 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Insert same repeated characters among words
Hi,
I have extracted some words with fixed length -
Code:
"liked years mouth click width exams forms genda coder codes table poorl poste franc repot derie cvang"
and I want to insert some characters among them (, and T), but what I wannt is that theres need to be placed repeatedly using this pattern:
Code:
"liked,years,mouth,clickTwidthTexamsTforms,genda,coder,codesTtableTpoorlTposte,franc,repot,derieTcvang"
Last edited by VB.NET Developer; Feb 27th, 2021 at 12:02 PM.
Please dont forget to add good reputation if my advices were useful for you.
-
Feb 27th, 2021, 04:17 PM
#2
Re: Insert same repeated characters among words
Code:
TextBox1.Text = TextBox1.Text.Re[;ace("liked years mouth click width exams forms genda coder codes table poorl poste franc repot derie cvang", "liked,years,mouth,clickTwidthTexamsTforms,genda,coder,codesTtableTpoorlTposte,franc,repot,derieTcvang")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 27th, 2021, 04:36 PM
#3
Thread Starter
Addicted Member
Re: Insert same repeated characters among words
Thanks, but this is not exaclty I am looking for...
I am looking for something that could be changed according to my needs (separator length, characters to replace), because I have another texts, but on these I need to use different character set as a replacement...
Please dont forget to add good reputation if my advices were useful for you.
-
Feb 27th, 2021, 08:38 PM
#4
Re: Insert same repeated characters among words
 Originally Posted by VB.NET Developer
I am looking for something that could be changed according to my needs
So something other than what you actually asked for in the first post then? Perhaps you should provide all the relevant information up front. That way, we won't be forced to guess or assume and then we can't guess or assume incorrectly. Don't just provide a single example because there are always going to be lots of ways that one example could be handled. What we need is the actual rules you want implemented, not an example of those rules implemented. In short, provide a FULL and CLEAR description of the problem.
-
Feb 28th, 2021, 06:16 AM
#5
Thread Starter
Addicted Member
Re: Insert same repeated characters among words
OK. I have many other words such as
"no to te be dc cu nt wi at de cz cm de re wo id st ri gp" etc
on these I want to insert different character set - "." and "3"
so output will looks like this:
"no.to.te.be.dc3cu3nt3wi3at.de.cz.cm.de3re3wo3id3st.ri.gp" etc
Another example:
"three fourth space reply quote salut words exeed toped cruze cajow" etc
on these I want to use another character set - "?" and "@"
"three?fourth@space?reply@quote?salut@words?exeed@toped?cruze@cajow"
So I am looking for universal solution that can be configured with parameters - separators, length. So basically replace space with repeated set of characters according the pattern.
Please dont forget to add good reputation if my advices were useful for you.
-
Feb 28th, 2021, 08:44 AM
#6
Re: Insert same repeated characters among words
I've read you Post(s) 4 times and still don't get it.
a guess would be to use Skip and Take in a Loop
quick samle (without Loop)
Code:
Dim input As String = "liked years mouth click width exams forms genda coder codes table poorl poste franc repot derie cvang"
Dim allWords = input.Split(New Char() {" "c})
Dim a = allWords.Skip(3).Take(4)
Debug.WriteLine(String.Join("T", a))
'returns:
'clickTwidthTexamsTforms
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Feb 28th, 2021, 10:09 AM
#7
Re: Insert same repeated characters among words
 Originally Posted by VB.NET Developer
OK. I have many other words such as
"no to te be dc cu nt wi at de cz cm de re wo id st ri gp" etc
on these I want to insert different character set - "." and "3"
so output will looks like this:
"no.to.te.be.dc3cu3nt3wi3at.de.cz.cm.de3re3wo3id3st.ri.gp" etc
Another example:
"three fourth space reply quote salut words exeed toped cruze cajow" etc
on these I want to use another character set - "?" and "@"
"three?fourth@space?reply@quote?salut@words?exeed@toped?cruze@cajow"
So I am looking for universal solution that can be configured with parameters - separators, length. So basically replace space with repeated set of characters according the pattern.
what is the logic of your sequences ?
on the first example in post #1, the sequence of replacement is 3 x ',' then 3 x 'T' and so on
on the the two examples above, the first one is 4 x '.' then 4 x '3', ...
on the third it is 1 x '?' then 1 x '@'....
is there other potential sequences ? (3 characters, different length for each ?)
you will need 1 variable for the length of the sequence, 2 variables for the character.
a "for each" loop to go through all character and a counter to change the character.
you check each character, if it is a space, change the space, increase the counter, if the counter reach the limit, change the replacement character and put the counter to 0, etc...
you put all that in a function : input : string, length, char1, char2. output : string
The best friend of any programmer is a search engine 
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
-
Mar 4th, 2021, 01:10 PM
#8
Thread Starter
Addicted Member
Re: Insert same repeated characters among words
what is the logic of your sequences ?
is there other potential sequences ? (3 characters, different length for each ?)
As I said prior - I am looking for universal solution that can be configured with parameters - separators, length. So basically replace space with repeated set of characters according the pattern.
I figured it out some days ago:
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim StrData As String
StrData = TextBox4.Text
StrData = Replace(StrData, " ", ",", , TextBox_K.Text)
StrData = Replace(StrData, " ", "T", , TextBox_P.Text)
TextBox4.Text = StrData
End Sub
Last edited by VB.NET Developer; Mar 16th, 2021 at 01:05 PM.
Reason: fixed errors in code
Please dont forget to add good reputation if my advices were useful for you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|