如何替换 space 字符之前的第十八个字符(不匹配这只匹配 space 字符)?

How can I replace the eighteenth character before space character (without match this only match the space character )?

我有一个字符串

"onetwomappleapplejackfire computer stringspaceredpineapple roughapplepainregex"

我想找到space之前的第十八个字符。

我有一个类似的命令来查找第十八个字符 after a space:

\s(?=.{18}(.))

替换为这 $1

我想这样做,但反过来。

我也在尝试回顾但不起作用

   (?<=(.).{18})\s

还有

     (?=(.).{18})\s

我无法捕获 $1 组

我希望命令在第一次匹配后不停止

还有 我希望命令在文本中找到所有 spaces(不跳过 space)

请帮帮我

正则表达式:(?<=([\w\s])[\w\s]{17})\s

演示 here