I have a text that is organized like this using punctuation “|
” from the closest example:
hello: one|three|two|four|
or sometimes the form comes in numbers, not letters
hello: 1|3|2|4|
Is there a possibility to move words or numbers from the second position to the third or vice versa?
To became like this (respectively):
hello: one|**two**|**three**|four|
hello: 1|**2**|**3**|4|
I used “**” to mark the changes.
Find the following regular expression:
hello: +(?:\w+\|){N}\K(\w+)\|(\w+)
and replace with
$2|$1
where N
is the number of words preceding the first one that you want to swap. In your example, N=1.
Demo screenshot:
Be sure to have checked the "Regular expression" mode.