Regex Remember all matches before substitution.

I have a list of 2 values ​​separated by a comma, for example:

A, 0xAA
B, 0xBB
C, 0xCC

etc .. I want to use notepad ++ and Regex to replace this list with a list of this form:

A-B-C
0xAA-0xBB-0xCC

The regular expression to match the pattern is as follows:

^(\w+), 0x(\w\w)$

But I do not know how to make a notebook a replacement of matches in the way I described. He would have to remember matches or something like that, I’m not even sure how to describe this behavior, and that’s probably why I haven’t found a solution yet.

+4
source share
3 answers

1.) Press and hold ALT-Key, select the second column of elements:

enter image description here

2.) Cut ( CTRL+X)and just paste below ( CTRL+V)

enter image description here

3.) "" ( - )

enter image description here

4.) Regex Replacement : ,?\s+ ( -)

enter image description here

5.) -#- (\r\n):

enter image description here

/ . 1,2,3, 4 5. , - ..

+2

Excel:

  • Excel
  • " → ". "", "" " " "{none" ), " ".
  • 1 ( "A", "B" ..) .
  • 2.
  • 2 Notepad ++ -.

:

A-B-C
0xAA-0xBB-0xCC
+1

As indicated, notepad ++ is not a good tool for this replacement, but if you really need to use it, the template for your simple example will be great:

template:

(\w)(,\s)(0x\w\w)\r\n(\w)(,\s)(0x\w\w)\r\n(\w)(,\s)(0x\w\w)

Replaced by:

$1-$4-$7 \r\n$3-$6-$9
0
source

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


All Articles