Using RegEx, I want to replace construction in my example into a div.
So, before:
::: foo
some text
:::
After:
<div class="foo">
some text
</div>
I found how it may be done (test), but my solution works for only one class. In other words, class is hard-coded into script:
<script>
document.body.innerHTML = document.body.innerHTML.replace(new RegExp(/(:::\s?[a-z])\w+/, 'g'), '<div class="foo">');
document.body.innerHTML = document.body.innerHTML.replace(new RegExp(/:::/, 'g'), '</div>');
</script>
How it may be changed, so it will work for any class name? For example, these constructions should be also converted into divs:
::: foobarfoo
some text
:::
and
::: foo-bar-foo_bar_foo123-foo
some text
:::