Home > Software design >  Remove parenthesis and Characters inside it
Remove parenthesis and Characters inside it

Time:11-20

I want to remove parenthesis along with all the characters inside it...

var str = B.Tech(CSE)2020;

print(str.replaceAll(new RegExp('/([()])/g'), '');

// output => B.Tech(CSE)2020
// output required => B.Tech 2020

I tried with bunch of Regex but nothing is working...

I am using Dart...

CodePudding user response:

Your Dart syntax is off, and seems to be confounded with JavaScript. Consider this version:

String str = "B.Tech(CSE)2020";
print(str.replaceAll(RegExp(r'\(.*?\)'), " "));  // B.Tech 2020
  • Related