正则表达式:查找所有不带“”的换行符作为前一个字符

发布于 2024-10-18 08:19:38 字数 921 浏览 9 评论 0原文

我有一个包含一堆数据的文件,如下所示:

"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"

这会重复多次(使用不同的数据)。我希望它看起来像这样:

"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"

我认为我需要的是某种方法来删除前面没有“的所有换行符,但我的正则表达式很弱。

我正在使用 Textwrangler (文本编辑器)对于 OS X)。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-10-25 08:19:39

这称为消极查找。这应该可以解决问题。

(?<!")\n

根据评论中的 @ax,在 Mac 上,您可能需要将 \n 更改为 \r,如下所示:

(?<!")\r

如果仍然不起作用,有时您可能需要将两者结合起来:

(?<!")\r\n

其中之一应该可以满足您的需求。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文