English 中文(简体)
Regex: Finding all line breaks without an " as previous character
原标题:

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).

问题回答

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

(?<!")

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

(?<!")

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

(?<!")

One of these should meet your needs.





相关问题
Uncommon regular expressions [closed]

Recently I discovered two amazing regular expression features: ?: and ?!. I was curious of other neat regex features. So maybe you would like to share some tricky regular expressions.

regex to trap img tag, both versions

I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />

C++, Boost regex, replace value function of matched value?

Specifically, I have an array of strings called val, and want to replace all instances of "%{n}%" in the input with val[n]. More generally, I want the replace value to be a function of the match ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

Is it possible to negate a regular expression search?

I m building a lexical analysis engine in c#. For the most part it is done and works quite well. One of the features of my lexer is that it allows any user to input their own regular expressions. This ...

regex for four-digit numbers (or "default")

I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...

热门标签