regex - 如何通过 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++
我需要的结果中使用哪个正则表达式。或者有更好的解决方案或编辑器。
解决方案
- 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
截图(之前):
截图(之后):
推荐阅读
- python - PyQt 在菜单栏上选择项目会加载一个新的框架/一组小部件
- php - PHP对两个多维数组的元素求和
- elasticsearch - JSON在列表中时如何匹配?
- bash - 如何将函数的输出存储在bash中的变量中
- javascript - 如何从按钮传递参数?
- python - Airflow - 任务中的并行执行
- mysql - MySQL选择仅具有值的列
- python - python traceback keyerror代码,用于在kaggle文本数据集上训练模型
- java - 偏移和限制的 SQLite 分页问题
- apache-kafka - kafka-reassign-partition.sh 不再接受 log_dirs 参数