Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  41] [ 1]  / answers: 1 / hits: 18609  / 12 Years ago, fri, february 1, 2013, 12:00:00

I'd like to remove character between { and }.



Example :



 input_string = i like apple {nobody knows};


expected result :



i like aple

More From » regex

 Answers
14

You can use



 var out = input_string.replace(/{[^}]*}/,'')


If you want to remove more than one occurrence, use



 var out = input_string.replace(/{[^}]*}/g,'')





To remove things between /* and */ , this one should work :



 var out = input_string.replace(/(?!<)/*[^*]+*/(?!)/g,'')

[#80474] Thursday, January 31, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidan

Total Points: 72
Total Questions: 95
Total Answers: 121

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
aidan questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Sep 29, 21, 00:00, 3 Years ago
Sun, Sep 5, 21, 00:00, 3 Years ago
Thu, Jan 16, 20, 00:00, 4 Years ago
;