首页 > 解决方案 > 如何通过 Note 更改文本格式

问题描述

我有如下翻译文件

THANK_YOU               =   Thanks for contacting us! We’ll get back to you as soon as possible.
Name                    =   Name
First                   =   First
Last                    =   Last
Email                   =   Email
Your Comments           =   Your Comments
Submit                  =   Submit

现在我需要像这样更改格式

'THANK_YOU'               =>   'Thanks for contacting us! We’ll get back to you as soon as possible.',
'Name'                    =>   'Name',
'First'                   =>   'First',
'Last'                    =>   'Last',
'Email'                   =>   'Email',
'Your Comments'           =>   'Your Comments',
'Submit'                  =>   'Submit'

并且不知道在Notepad++我需要的结果中使用哪个正则表达式。或者有更好的解决方案或编辑器。

标签: regexnotepad++

解决方案


  • Ctrl+H
  • 找什么:^(.+?)(\h+=)(\h+)(.+)$
  • 用。。。来代替:"$1"$2>$3"$4"
  • 检查 环绕
  • CHECK 正则表达式
  • 取消选中 . matches newline
  • Replace all

解释:

^               # beginning of line
  (.+?)         # group 1, 1 or more any character but newlines, the text before equal sign
  (\h+=)        # group 2, 1 or more horizontal spaces and equal sign
  (\h+)         # group 3, 1 or more horizontal spaces
  (.+)          # group 4, the text after the equal sign
$

替代品:

"$1"            # content of group 1 surround by quotes
$2              # content of group 2
>               # literally >
$3              # content of group 3
"$4"            # content of group 4 surround by quotes

截图(之前):

在此处输入图像描述

截图(之后):

在此处输入图像描述


推荐阅读