TheTanadu
TheTanadu

Reputation: 684

How to add "backspace character" to regex output change in vscode?

I have file containing around ~1400 lines. In each line there are infomation + in next line is next information which I want move "to previous" line (where is text)

I tried " for" changing into "\r |" - only that was coming to my head in that time.

For example here it's "structure" of my file:

T="topic 1"
 for [email protected]
T="topic 2"
 for [email protected]

I wanted move that to clear into that

T="topic 1" | for [email protected]
T="topic 2" | for [email protected]

Upvotes: 7

Views: 6121

Answers (2)

The fourth bird
The fourth bird

Reputation: 163427

Another option if you don't want keep for could be to match:

\n[ \t]+for[ ]

That will match:

  • \n Match a line break
  • [ \t]+ Match 1+ times a space or char (Or just a single space if that is the case)
  • for[ ] Match for followed by a space (the square brackets are for clarity only

And replace with a space, a pipe followed by a space

|

Regex demo

Upvotes: 1

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627022

You may use

Find what:      \n( for)\b
Replace with: |$1

Details

  • \n - a line break
  • ( for) - Capturing group 1 ($1): a space and for
  • \b - word boundary.

Test result:

enter image description here

Upvotes: 4

Related Questions