const regex = /^(([.#]?[\w:>]+,?\s*)+){/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(([.#]?[\\w:>]+,?\\s*)+){', 'gm')
const str = `.rn_CircleImage {
float: right;
color: white;
margin-right: 4vw;
border: 1px solid black;
background: black;
border-radius: 50%;
/* padding-bottom: 20%; */
width: 280px;
height: 280px;
margin-top: -260px;
text-align: center;
vertical-align: middle;
position: relative;
margin-bottom: 4%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
}
.rn_Hero .rn_HeroInner {
background-image: url("/euf/assets/themes/standard/images/CS11572.jpg") !important;
}
.rn_CircleImage .textContainer {
height: 200px;
}
.dot,
.period {
cursor: pointer;
height: 10px;
width: 10px;
background-color: #717171;
border-radius: 50%;
display: inline-block;
position: relative;
transition: background-color 0.6s ease;
bottom: -35px;
}
.active, .dot:hover {
background-color: #ffffff;
}
.rn_CircleImage>li>a {
color: #FFFFFF;
}
.urltext a {
color: #FFFFFF;
line-height: 24px;
font-family: "CS-Type-EP", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.top {
font-size: 1em;
font-family: "CS-Type-EP", "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 24px;
}
.bottom {
font-size: 1em;
font-family: "CS-Type-EP", "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 24px;
margin-bottom: 6px;
}
.main {
font-size: 1.87em;
font-family: "CreditSuisseHeadlineWebRegular", "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 34px;
}
.slide>li {
width: 100%;
}
ul.slide {
width: auto !important;
padding-left: 10%;
padding-right: 10%;
}
.slide>li:after {
content: "";
display: inline;
width: 50%;
height: 0;
padding-bottom: 50%;
background: #4679BD;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.urltext a {
color: #FFFFFF;
line-height: 30px;
font-family: "CS-Type-EP", "Helvetica Neue", Helvetica, Arial, sans-serif;
background: transparent url(/euf/assets/themes/standard/images/icons/arrow-right-white.svg) no-repeat right center;
padding-right: 1.7em;
background-size: 1em;
position: absolute;
transition: background-color 0.6s ease;
bottom: 18%;
right: 28%;
}`;
const subst = `#prefix $1{`;
// 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