So I am a typography-nazi (they are like grammar-nazis on steroids), and I have a string, which might contain multiple level double quotes, such as:\[code\]$str = 'Outer text "first level "second level "third level" second level" first level" outer text';\[/code\]In my native language, a maximum of three level quoting is typographically correct, with each level having its own quotation mark. I would like to replace all the double quote pairs to their corresponding entities, such that:
- 1st level: „text” (\[code\]„\[/code\] and \[code\]”\[/code\])
- 2nd level: »text« (\[code\]»\[/code\] and \[code\]«\[/code\])
- 3rd level: ’text’ (\[code\]’\[/code\])
- any additional levels: ’text’ (\[code\]’\[/code\])