Ad

Typoscript Regex Replacement Asterisk To Bold?

- 1 answer

I have a string where I want to replace text surrounded by asterisks *text* to html <b>text</b> using typoscript replacement with regex.

So far I have got:

stdWrap.replacement {
    10 {
        search = /\*[^*]+?\*/
        replace = <b>$1</b>
        useRegExp = 1
    }
}

But this seems to replace the text with an empty <b></b>?

Ad

Answer

I'm not an regex guy but if you change your search string to this, it should work

stdWrap.replacement {
    10 {
        search = /\*(.*?)\*/
        replace = <b>$1</b>
        useRegExp = 1
    }
}
Ad
source: stackoverflow.com
Ad