Insert a newline after each dot using regex

Hello :wave:

How I can insert a new line after each dot using regex?

  • I'm using the chrome extension.

Thanks.

You can replace dot symbol on new line (tab) by using Excel after you scraped what you need...

1 Like

Thanks don, I found this solution:

  1. I used (Grouped Selector) so I got JSON output

  2. Then I used this code to make a function in Google Sheet > Apps Script

function convertJsonToText(jsonString) {
  var jsonData = JSON.parse(jsonString);
  var plainText = '';
  
  // Recursive function to traverse through the JSON object
  function traverse(obj, depth) {
    for (var key in obj) {
      if (typeof obj[key] === 'object') {
        traverse(obj[key], depth + 1);
      } else {
        var indent = ' '.repeat(depth * 2); // Adjust the number of spaces for indentation
        plainText += indent + key + ': ' + obj[key] + '\n' + '\n';
        // Add an extra empty line after each dot
        if (key === '.') {
          plainText += '\n';
        }
      }
    }
  }
  
  traverse(jsonData, 0);
  
  return plainText;
}