Regex Replace Whitespaces between single quotes

丶灬走出姿态 提交于 2019-12-23 02:19:15

问题


I'm trying to find and replace a string into the wanted string, but can't get it to work.

For example:

1777: '23.5R25 Bridgestone VLT **',

Should be:

1777: '23.5R25-Bridgestone-VLT-**',

I'm having like 1,700 lines like this and want every whitespace between the single quotes to dashes. I'm using Notepad++ for this.

My approach:

Find: '(.*?)\s+(.*?)'

Replace: '\1-\2'

But this works for just 2 words.


回答1:


\s(?!(?:[^']*'[^']*')*[^']*$)

You can use this and replace by -.See demo.

https://regex101.com/r/vP2zF2/2



来源:https://stackoverflow.com/questions/33363744/regex-replace-whitespaces-between-single-quotes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!