Regex replace to change the order of words in a sentence

前端 未结 4 1580
遇见更好的自我
遇见更好的自我 2020-12-17 03:20

If I have a string like this:

\"word1 \'word2\' word3\"

is it possible to use a regex replace to change the string to this:

4条回答
  •  一向
    一向 (楼主)
    2020-12-17 03:52

    Following the other suggestions...

    this expression will make sure that word3 is the final word in the string (forward look for " and then end-of-string), but allows for any characters for your 'words' except single and double quotes.

    ('[^']+?')\s+([^"]+?(?>"))$

提交回复
热议问题