2

I have a file with a bunch of data looking like this:

"sc14b61ecf5ef162","sc14b61b07ba1690","1264806000","1264806000","780","1080","Navn arrangement:
Dørene åpner:
Arr.start:
Arr:slutt:
Dørene stenger:
HA (navn):
HA (tlf):
Type arrangement: (her: om konsert, gjerne sjanger)
Forvetet antall gjester:"
"sc14b61f9e35f569","sc14b61bf07647db","1265583600","1265583600","1020","1260","Nord/Sør
Foredrag
Ønsker skjenking"

This repeats itself many times (with different data). I would like it to look like this:

"sc14b61ecf5ef162","sc14b61b07ba1690","1264806000","1264806000","780","1080","Navn arrangement:Dørene åpner:Arr.start:Arr:slutt:Dørene stenger:HA (navn):HA (tlf):Type arrangement: (her: om konsert, gjerne sjanger)Forvetet antall gjester:"
"sc14b61f9e35f569","sc14b61bf07647db","1265583600","1265583600","1020","1260","Nord/Sør Foredrag Ønsker skjenking"

I think that what I need is some way to remove all line-breaks that does not have an " in front of it, but my regex is weak.

I'm using Textwrangler (the text editor for OS X).

1 Answers1

3

This is called negative look behind. This should do the trick.

(?<!")\n

Per @ax in the comments, on a Mac, you may need to change the \n to \r like so:

(?<!")\r

If that still doesnt work, sometimes you may need to combine the two:

(?<!")\r\n

One of these should meet your needs.

Jeff
  • 13,943
  • 11
  • 55
  • 103
  • on a mac, this would be `(?<!")\r` – ax. Feb 21 '11 at 19:02
  • ive never had problems with just \n but youre right. Some programs or OSes also do \r\n – Jeff Feb 21 '11 at 19:15
  • 1
    for textwrangler on os x, it most probably is only `\r`: see this screenshot: http://www.barebones.com/products/textwrangler/textwranglerpower.html – ax. Feb 21 '11 at 19:34
  • oh well: the newline representation for OS X is LF, \n: http://en.wikipedia.org/wiki/Newline#Representations – ax. Feb 21 '11 at 19:53
  • I know on windows, I have seen applications go any of these ways. I assumed Mac would be similar but I have never looked into it enough to test. – Jeff Feb 21 '11 at 20:07