The string I work on looks like that:
abc {def ghi {jkl mno} pqr stv} xy z
And I need to put what figure parentheses are containing in tags, so it should looks like this
abc <tag>def ghi <tag>jkl mno</tag> pqr stv</tag> xy z
I’ve tried
'#(?<!\pL)\{ ( ([^{}]+) | (?R) )* \}(?!\pL)#xu'
but what I get is just <tag>xy z</tag>. Help please, what am I doing wrong?
How about two steps:
s!{!<tag>!g;s!}!</tag>!g;(perl format; translate to your format as appropriate)
or maybe this:
1 while s!{([^{}]*)}!<tag>$1</tag>!g;