Add a new line after a matched pattern in Notepad++

痴心易碎 提交于 2021-02-02 09:50:46

问题


I have a csv-file, now i need to bring it in another form.

I want to have a line break \r\n after a specific pattern.

All patterns look like this:

true or false; int number between 0 and 100; decimal number with two or three digits after the point; true or false;

For example:

false;2;23.987;false;
true;0;8.37;false;
false;8;166.987;false;

and after the last semicolon, i want to have a line break. I am using notepad++.

Thanks for your help


回答1:


You may use

\b(?:true|false);\d+;\d+\.\d+;(?:true|false);

or a more precise acc. to your specs:

\b(?:true|false);(?:\d{1,2}|100);\d+\.\d{2,3};(?:true|false);

and replace with $0\r\n.

Details:

  • \b - word boundary
  • (?:true|false) - a non-capturing group matching either true or false
  • ; - a literal ;
  • (?:\d{1,2}|100) - either any 1 or 2 digits or 100
  • ; - a semi-colon
  • \d+\.\d{2,3} - 1+ digits, a literal . and then 2 or 3 digits
  • ; - a ;
  • (?:true|false) - again either true or false
  • ; - finally, the last semi-colon.



来源:https://stackoverflow.com/questions/39972913/add-a-new-line-after-a-matched-pattern-in-notepad

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