You can use regex for this:
First I edited your example so that the starting and desired results are different (assuming this is your desired result here based on what you wrote)
library(dplyr)
library(stringr)
df <- data.frame("position" = c("ante", "ex", "post", "post pre ante", "post pre", "ante post pre", "ex pre", "pre ante"))
df
#> position
#> 1 ante
#> 2 ex
#> 3 post
#> 4 post pre ante
#> 5 post pre
#> 6 ante post pre
#> 7 ex pre
#> 8 pre ante
df2 <- data.frame("position" = c("ante", "ex", "post", "post pre ante", "pre post", "ante post pre", "pre ex", "pre ante"))
df2
#> position
#> 1 ante
#> 2 ex
#> 3 post
#> 4 post pre ante
#> 5 pre post
#> 6 ante post pre
#> 7 pre ex
#> 8 pre ante
Then using regex:
df3 <- df %>%
mutate(position = str_replace(position,'^([^\s]+) {1}(?=pre$)(pre)','\2 \1'))
df3
#> position
#> 1 ante
#> 2 ex
#> 3 post
#> 4 post pre ante
#> 5 pre post
#> 6 ante post pre
#> 7 pre ex
#> 8 pre ante
identical(df2, df3)
#> [1] TRUE
Slight edit:
I think the lookahead was unnecessary so we can reduce this to:
df3 <- df %>%
mutate(position = str_replace(position,'^([^\s]+) {1}(pre)$','\2 \1'))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…