How to locate and replace the 2ND occurence of "(" in a text?

Cool, I am building your blocks halfway and the improvie=sed version comes up. Ok, let me try the new one. :laughing:

Sure.

But you can drag-n-drop image in builder

Actually replace all will replace all occurences.

Oh. yes. That is also the issue where we have to put in a lot of code instead of the replace method. It kinda annoys me. Maybe :kodular: will bring a new block for this in future? :pray:


Actually, I don’t understand this solution. Where is the part where the solver splits each character? It seems like by "split text at " “”, he is splitting the one word from another word, right? Each item in the list contains a word not a character right? But of course I tried it out and the solution is correct, I just don’t understand the code well enough

And why remove list item index 1?

Hello. Let me explain. (This post is from me.)
split text at ""will split every single text into a list
but the first item in the list is empty (because you split at “”)
so i hv to remove it

1 Like

Oh I thought smth else.

Wow. Didn’t expect the original owner here :laughing: Thanks! you mean " “” will split every single [character] into a list"? Not every single word into a list right? I thought that " " equals [space], so it splits words. So, maybe “” and " " is different when using the pink block to split text? Because they both look the same in the picture an empty pink block.

1 Like

Yes, exactly. This method is used in many things, also see

:grin: :grin:

1 Like

I see. :grin: My bad. Needs more experience :rofl: and carefulness


Tried your code, this is what it turned out to be. I don’t think it did as it was supposed to. Did I miss anything?

I think no.
“” (empty string) will split every character in list while " "(space) will split every word in list.

1 Like

I tried your code. Please see above. Essentially it needs to get (a b (c d)) to ((a b) (c d))

Probably you have to remove " from result before returning it.
Also try setting count variable to 1 in local variable.

I will try it. Thank you.
I just tried saving ((a b) (c d)) string into a variable then try to read it and I failed. Not sure if I am ding something wrong. Should I open a new thread for this or, do you think it is pointless?

this ((a b) (c d)) can be a list of lists or a string. If it is a string, you can’t convert it into a list of lists, you therefore should save your lists correctly to avoid your issue.

Edit: use the is a list? block to find out, that a string like this ((a b)(c d)) is not a list
what you can do is to use the list from csv table block to convert a string like a,b\nc,d to a list of lists

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun
PS: yes, please start a new thread, this one is a mess and I will close it therefore.

2 Likes