Page 1 of 1

Joining lines

Posted: Fri Sep 24, 2010 6:54 pm
by srive99
Hi All,

I have an ldif file which is exported from LDAP and its got thousands of lines and some of the DN's are spilted into two lines. How can we can join those lines.

I can do shift J, but since I have thousands of lines that is not good idea.

Here is example of my file
dn: cn=abc,ou=syc,=myorg,o=org
dn: uid=role_ab cd, ou=qaz,ou, edc,
ou=roles,ou=org
dn: cn=abcd,ou=syc,=myorg,o=org
dn: uid=role_ab cd, ou=qaz,ou=edc_
dcf & sync, ou=roles,ou=org
dn: uid=role_ab&sync, ou=qazd,ou=syx -
dcf & sync, ou=roles,ou=org
Thanks[/quote]

Posted: Sat Sep 25, 2010 12:54 pm
by ben_josephs
This is not easy to do with TextPad's regex recogniser because of its limited functionality by the standards of modern tools.

But this should solve your specific problem. It searches for lines whose first character isn't a d or whose second character isn't an n. This is messy and can't readily be genaralised to other similar problems.
Find what: \n([^d]|.[^n])
Replace with: _\1 [Replace the underscore with a space]

[X] Regular expression

Replace All
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax