Keep characters in replace with regex in gedit

Asked

Viewed 109 times

2

I have the following text segment in a . csv file

5/29/17;08:17;Fulano;Teatro Companhia
Rua do Canto, 301/305
Esquina da rua meio
De segunda a sexta das 9h as 18h
5/29/17;08:18;Ciclano;legal

I need lines 2,3 and 4 to be together with line 1 separated by "|" and for that I used the following regular expression to locate line breaks that do not start with a number

\n[^[0-9]

but when I ask to replace it erases the first letter of each line and the file looks like this:

5/29/17;08:17;Fulano;Teatro Companhia|ua do Canto, 301/305|squina da rua meio|e segunda a sexta das 9h as 18h
5/29/17;08:18;Ciclano;legal

I wonder how I can use an expression that locates desired occurrences without deleting the characters that start the next line.

I am using the Gedit program to do this process, with the find and replace command.

1 answer

2


You need to use a Lookahead positive:

\n(?=[^0-9])

This operator does with the regular expression see if the following character matches the given expression. In this case, check that the character following the new line \n is not a number.

You can see an example here (in C#).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.