const regex = /(?:[\S]+received_bytes_count )(?:true|false) ([\S]+)|(?:[\S]+received_bytes_count )([\S]+) (?:true|false)|(?:[\S]+received_bytes_count )([\S]+)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?:[\\S]+received_bytes_count )(?:true|false) ([\\S]+)|(?:[\\S]+received_bytes_count )([\\S]+) (?:true|false)|(?:[\\S]+received_bytes_count )([\\S]+)', 'g')
const str = `compute.googleapis.com/instance/network/received_bytes_count fleetwood false
compute.googleapis.com/instance/network/received_bytes_count false graceland
compute.googleapis.com/instance/network/received_bytes_count false creedence
compute.googleapis.com/instance/network/received_bytes_count false gke-oamstest-default-pool-bcb12758-nvb9
compute.googleapis.com/instance/network/received_bytes_count gke-oamstest-default-pool-bcb12758-nvb9 true
compute.googleapis.com/instance/network/received_bytes_count gke-oamstest-default-pool-bcb12758-6bzw false
compute.googleapis.com/instance/network/received_bytes_count true gke-oamstest-default-pool-bcb12758-6bzw
compute.googleapis.com/instance/network/received_bytes_count gke-oamstest-default-pool-bcb12758-s4td false
compute.googleapis.com/instance/network/received_bytes_count true gke-oamstest-default-pool-bcb12758-s4td
compute.googleapis.com/instance/network/received_bytes_count gke-oamstest-default-pool-bcb12758-nvb9
compute.googleapis.com/instance/network/received_bytes_count gke-oamstest-default-pool-bcb12758-6bzw
compute.googleapis.com/instance/network/received_bytes_count gke-oamstest-default-pool-bcb12758-s4td
`;
const subst = `$1$2$3 Rcvd`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions