Regex modify the article format: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 1: Line 1:


== Case 1: From 1) to (return symbol) 1. ==
== Case 1: From 1) to 1. ==
=== Purpose ===
=== Purpose ===


Convert the paragraph from: 1) ... to (return symbol) 1. ...
Convert the paragraph from: 1) ... to 1. ..., and add return symbol at the beginning each row


original paragraph:
original paragraph:
Line 32: Line 32:
=== Purpose ===
=== Purpose ===


Convert the paragraph from: 1. ... to (return symbol) 1. ...
Add return symbol at the beginning each row if start with integer


original paragraph:
original paragraph:

Latest revision as of 16:51, 9 March 2023

Case 1: From 1) to 1.[edit]

Purpose[edit]

Convert the paragraph from: 1) ... to 1. ..., and add return symbol at the beginning each row

original paragraph:

1) ... 2) ...

to:

1. ...
2. ...

Approach[edit]

After enabled the regular expression of the text editor such as Notepad++ or Sublime Text $

  • Find: \s?(\d\d?)(\))\s+
  • Replace with: \n$1\.\s


Example data[edit]

1) Generation Alpha is digitally-orientated and informed, leading to increased brand loyalty and consumer alertness. 2) Mental wellbeing is a key factor in consumer decision making and a disrupted lifecycle pattern will influence consumption habits. 3) Resource scarcity, health and sustainability are key factors for the future of consumption.


Case 2: From 1. to (return symbol) 1.[edit]

Purpose[edit]

Add return symbol at the beginning each row if start with integer

original paragraph:

1. ... 2. ...

to:

1. ...
2. ...

Approach[edit]

After enabled the regular expression of the text editor such as Notepad++ or Sublime Text $

  • Find: \s?\b(\d\d?\.)\s+
  • Replace with: \n$1 Note: end with one whitespace