const regex = /([\.#,A-z0-9-_]*)[\s]*:[\s]*([#%A-z0-9-\s''\"\",.\/\\\(;=:+\)]*);/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('([\\.#,A-z0-9-_]*)[\\s]*:[\\s]*([#%A-z0-9-\\s\'\'\\"\\",.\\\/\\\\\\(;=:+\\)]*);', 'gm')
const str = ` background-image: url(data:image/svg+xml
base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSI1MHB4IiBoZWlnaHQ9IjEzMnB4IiB2aWV3Qm94PSIwIDAgNTAgMTMyIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjwhLS1HZW5lcmF0b3I6IFNrZXRjaCA1MC4yICg1NTA0NykgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gtLT48dGl0bGU+UGF0aCA1PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZyBpZD0iSG9tZS1wYWdlIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48ZyBpZD0iMjAxOC0wMy0yOF9faG9tZV9fZGVza3RvcCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE0NzYuMDAwMDAwLCAtNDM2OS4wMDAwMDApIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMyI+PGcgaWQ9Ikdyb3VwLTMwLUNvcHkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDExMDQuMDAwMDAwLCA0MzI1Ljg1MzQ4MikiPjxwb2x5bGluZSBpZD0iUGF0aC01IiBwb2ludHM9IjM3My4zNzY3MDEgNDQuNzExMjE4OSA0MTkuMjc4NDg3IDExMC40NzkwMyAzNzMuMzc2NzAxIDE3My45MjIwNzMiLz48L2c+PC9nPjwvZz48L3N2Zz4=);
.sauce .c-donate-hero {
max-width: 130rem;
max-inline-size: 130rem;
background-image: url(/homepage-9df4b/static/hero-2883d5a72882170fcfabc811b4a46b3b.jpg);
background-position: top left 3rem;
background-repeat: no-repeat;
background-size: 75% auto;
margin: 0 auto;
padding-top: 70vw;
padding-bottom: 5.6rem;
-webkit-padding-after: 5.6rem;
padding-block-end:5.6rem;}
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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