Question: I have an express app that I start in terminal with following command to enable debug logs in it:

```
DEBUG=custom:* npm start (on Ubuntu)
SET DEBUG=custom:* & npm start (on Windows)

```

On production server, I start app with PM2 using following command:

```
pm2 start bin/www -i 0

```

But this does not enable the `debug` logs in my code, so the debug statements are not added to the logs, only `console.error()` are added to the log files. How can I pass the `DEBUG=custom:*` option while starting my app with PM2?

Answer: 
You can parse it yourself with a function, here's an example:

```
function getTextWithInputValues(id) {
    var element = document.getElementById(id);
    if (!element) {
        return null;
    }

    var elementText = element.innerHTML; // Get the entire text from your element

    var elementInputs = element.getElementsByTagName('input'); // fetch all inputs from your element

    // replace all input fields with their respective values
    Object.getOwnPropertyNames(elementInputs).forEach(
        (input) => {
            var inputText = elementInputs[input].outerHTML;
            if (elementText.search(inputText) > 0) {
                elementText = elementText.replace(inputText, elementInputs[input].value);
            }
        }
    );

    return elementText;

}

```

You can test it right here by opening a console, paste this code in, then type in something in the search box on the top of the page (don't click search, just type in something), then when you call the function in the console like `getTextWithInputValues('search')` it will output something like 

```
<svg ......</svg>
your-text-here
<button .....</button>

```

Hope this helps.
Even though you asked for `REGEX`, I don't believe it is by any means needed.

This will return the data in an array. With the first index being the body text, and each input field value thereafter.

```
var values = [];
values.push($('#body').text());

var inputs = $('#body input');

for(var i = 0; i < $(inputs).length; i++)
{
    var currentElement = $(inputs)[i];
    values.push($(currentElement).val());
}

console.log(values);

```