草庐IT

php - 使用 php regexp 重新排序字符串的行

我需要使用phpregexp对字符串中的行重新排序。但我不知道如何告诉php不要将同一行更改两次。让我解释一下。输入字符串是:$comment="sometext{Varinat#3smth}{Varinat#4smthelse}{Varinat#1smthelse1}someanothertext{Varinat#2smthelse2}{Varinat#5smthelse5}";我需要订购变体:$comment="sometext{Varinat#1smthelse1}{Varinat#2smthelse2}{Varinat#3smth}someanothertext{Varinat