Putting curly braces in a sentences for specific words according to their start and end indexes
        Posted  
        
            by 
                Suneeta Singh
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Suneeta Singh
        
        
        
        Published on 2012-11-16T10:32:28Z
        Indexed on 
            2012/11/16
            11:00 UTC
        
        
        Read the original article
        Hit count: 247
        
java
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?
© Stack Overflow or respective owner