如何重新格式化 .txt 文件中的文本

如何重新格式化 .txt 文件中的文本

我在记事本文件中有一些数据库信息,它看起来像这样;

    firstname:lastname
    =====
    [Age]: Answer
    [Sex]: Answer
    [Height]: Answer
    [Shoe]: Answer
    =====

    firstname:lastname
    =====
    [Age]: Answer
    [Sex]: Answer
    [Height]: Answer
    [Shoe]: Answer
    =====

    firstname:lastname
    =====
    [Age]: Answer
    [Sex]: Answer
    [Height]: Answer
    [Shoe]: Answer
    =====

例如,我希望出现在一行上;

firstname:lastname=====[Age]: Answer[Sex]: Answer[Height]: Answer[Shoe]: Answer=====
firstname:lastname=====[Age]: Answer[Sex]: Answer[Height]: Answer[Shoe]: Answer=====
firstname:lastname=====[Age]: Answer[Sex]: Answer[Height]: Answer[Shoe]: Answer=====

如果可能的话,实现这一目标的最佳方法是什么?

答案1

  • Ctrl+H
  • 找什么:\R(?!\R)
  • 用。。。来代替:LEAVE EMPTY
  • 检查环绕
  • 检查正则表达式
  • Replace all

解释:

\R      : any kind of linebreak
(?!\R)  : negative lookahead, make sure we don't have another linebreak after

给定示例的结果:

firstname:lastname=====[Age]: Answer[Sex]: Answer[Height]: Answer[Shoe]: Answer=====
firstname:lastname=====[Age]: Answer[Sex]: Answer[Height]: Answer[Shoe]: Answer=====
firstname:lastname=====[Age]: Answer[Sex]: Answer[Height]: Answer[Shoe]: Answer=====

相关内容