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

How can I locate and replace the 2nd occurence of “(” in a text?
For example, For the text:
(a b **(**c d))
I would like to replace the 2nd “(” with “)(”

Wait I am working on your solution… I would tell you the idea behnd it, but it’s better to just give the blocks to you. :wink:


Also, see this Daily challenge for ideas:
Daily Challenge #71 :wink:

1 Like

Appreciate it. Am at a loss, because replacing seems to need to be made to all occurences. Not to a specific position. And how in the first place can we get the specific position of the 2ND, 3RD… occurence? Hmmm…

Of course, without knowing these the issue won’t work. We have to kill two birds with one stone :rofl:

Ok, I am at a loss. But I saw someone using “$” signs to process texts, do you know how that works? Like this ‏مجموعات Google

Wow, looking at the link you gave me, it seems that formatting text is quite complicated. I thought it is all about connecting 2 or 3 blocks together :laughing:

Hi @yulius
Do you want to replace ( or "(" ?
Also please show us what you have tried.

I want to replace (
I am still studying challenge 71. Sorry a little slow here, I am a newbie.

Actually I want to turn (a b (c d)) into ((a b) (c d))

You mean list of lists.

But then you will have to add another “(” in front and you did’nt say this.

Yes, because the list I got from firebase is a little strange.

Yeah I thought that if I know how to replace the 2nd occurence, the first occurence wouldn’t be too different.

Wait, what? I thought it was a string in which we have to change a digit, not a list! :open_mouth:

You will get data from firebase in same way as you have saved it.

What is happening here?

6 replies in a minute…

Now, @yulius, is your input a list or a string???

No, I saved it and it comes out in (a b (c d)) format. Maybe because I appended a new list to an old list

(a b (c d)) <-- I consider that a string, which can be turned into a list of list if it becomes ((a b) (c d)), am I wrong? Sorry I have no idea.

This is the way in normal lists:

blocks (23)

And nothing wrong with the format… :roll_eyes: