Putting curly braces in a sentences for specific words according to their start and end indexes
- by Suneeta Singh
I need to put curly braces in a sentence according to the indexes. Suppose my input sentence is: "I am a girl and I live in Nepal." and I need to put curly braces according to
[12, 15], [2, 4], [23, 25]
These indexes are corresponding to the words "am", "and" and "in" respectively.
The required output should be:
"I {am} a girl {and} I live {in} Nepal."
I have tried using substring but after it replaces first word, it then shifts the characters by two indexes and that is the problem I am having.
Can anyone provide me solution to get the required output?