Can this find / replace done with one regex?

Currently, I can accomplish what I'm trying to do by doing a few searches / replacements in Notepad ++, but I was wondering if I can make this more efficient using regular expressions. Preferably one search regular expression and a single regular expression. I am new to regex, so I did not know how to start this.

That's what I'm doing right now

Search: Sequence:\s

Replaced by: Seq\t\tName\t\t\t\tDescription\t\t\t\tAction\t\tEnabled\n

Then

Search: BR\sName:\s

Replaced by: \t

And similarly for each type, sequence, BR name, BR description, BR and Enabled actions.

Here is an example of the text I am editing:

Sequence: 40    BR Name: ROUTE PARTIAL  BR Description: ROUTE PARTIAL   BR Action: AFTER ROUTE  Enabled: Y

Here's what it looks like after editing:

Seq     Name                Description             Action      Enabled
40      ROUTE PARTIAL       ROUTE PARTIAL           AFTER ROUTE Y   

Any help would be greatly appreciated :)

+4
source share
1

Sam :

  • :

    ^([^\s:]+):\s(.*?)\s+BR\s([^\s:]+):\s(.*?)\s+BR\s([^\s:]+):\s(.*?)\s+BR\s([^\s:]+):\s(.*?)\s+([^\s:]+):\s.*?$
    
  • :

    \1\t\t\3\t\t\t\t\5\t\t\t\t\7\t\t\9\n\2\t\t\t\4\t\t\t\6\t\t\t\t\8\t10
    
+1

Source: https://habr.com/ru/post/1544043/


All Articles