Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove the spaces between the closing and opening tag in html with Dart

I followed some discussions in StackOverflow to get help to resolve my issue specific to Dart. I used the regex command to remove the place between the closing and opening tags in HTML. But it did not work for me.

Code

import 'dart:html';
void main() {
 var result = '<div><div><ul> <li>Chair</li>  <li>Table</li>  <li>Fan</li></ul><div></div>'.replaceAll(RegExp(r'/>\s+</gim'), '><');
  print(result);
}

Actual Result

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<div><div><ul> <li>Chair</li>  <li>Table</li>  <li>Fan</li></ul><div></div>

Expected Result

<div><div><ul><li>Chair</li><li>Table</li><li>Fan</li></ul><div></div>

I would like to know what type of change I need to do in my regex to get the expected result.

Thanks, in advance.

>Solution :

Change to:

.replaceAll(RegExp(r'>\s+<'), '><')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading