Remove all spaces before a specific symbol/character in a text file using notepad++

时间:2021-10-20 20:23:24

Okay I'm trying to set up a set of tag lists for a translation script but have encountered a problem I need to remove the spaces in one of the languages using regex

好吧我正在尝试为翻译脚本设置一组标签列表,但遇到了一个问题我需要使用正则表达式删除其中一种语言的空格

the lines are set up like "JP JP":"ENG ENG" and I would like it to be "JPJP":"ENG ENG"

线路设置如“JP JP”:“ENG ENG”,我希望它是“JPJP”:“ENG ENG”

I'm new when it comes to regex so I'm out of ideas of what to try

当谈到正则表达式时,我是新手,所以我不知道该尝试什么

Thanks!

谢谢!

2 个解决方案

#1


1  

Try this, this expression uses positive lookahead

试试这个,这个表达式使用正向前瞻

\s+(?=\w+":")

#2


0  

You can use Unix utility sed

你可以使用Unix实用程序sed

sed -i 's/old_name/new_name/g' your-file 

In your example this should be:

在你的例子中,这应该是:

sed -i 's/"JP JP":"ENG ENG"/"JPJP":"ENGENG"/g' your-file 

#1


1  

Try this, this expression uses positive lookahead

试试这个,这个表达式使用正向前瞻

\s+(?=\w+":")

#2


0  

You can use Unix utility sed

你可以使用Unix实用程序sed

sed -i 's/old_name/new_name/g' your-file 

In your example this should be:

在你的例子中,这应该是:

sed -i 's/"JP JP":"ENG ENG"/"JPJP":"ENGENG"/g' your-file