Discuss Scratch

madelynGH
Scratcher
55 posts

Split text by string?

I am trying to split text by a certain string. I know how to split it at a certain character, but how do I split it at a certain string? My code plan is:

Split (Text) at (String)

Iterate through and create a string
Check if the (length of string) characters of the variable add up together to make the string
Iterate through the characters until it gets to the first digit of the string
Put them in a new variable
Do the same thing to the characters after until the index is the last digit

But I get a different result.

When I try to use the function I made, it just turns out as “12345” when I try to split it by “23”. I'm trying to get the result of “145” when splitting it by “23”, for example.

I have also tried slightly changing my code. I just went through it, looking for bugs, and I found the problem.

The string I was trying to test to check if it's “23”, for example, was blank.

But I have no idea how to fix it.

Please help!!
deck26
Scratcher
1000+ posts

Split text by string?

So is the project shared?
madelynGH
Scratcher
55 posts

Split text by string?

deck26 wrote:

So is the project shared?
No, it isn't. If I share it, I'll get a lot of spam asking what it is.
deck26
Scratcher
1000+ posts

Split text by string?

Hard for us to help if we can't see it!
madelynGH
Scratcher
55 posts

Split text by string?

deck26 wrote:

Hard for us to help if we can't see it!
I mean, I'm not really asking for bug fixing, just code made from scratch.
blablablahello
Scratcher
1000+ posts

Split text by string?

pretty sure just treating the string as a single character should work (if it doesnt, you might wanna use a function where you would find the first letter of the string, than check the second and so on until you are sure either the one u found is or isnt a string, than you can use that function to find each string and split it according to the location of the string)

Powered by DjangoBB