Why can't Atom find these newlines?

2019-07-28 23:50发布

问题:

I'm trying to clean up a bunch of .vcf files that have line breaks in them and having trouble getting Atom to find the line breaks. Usually either \r, \n or \r\n will work if "regex" is selected but in this case it isn't finding blank lines at all. Here's a selection:

BEGIN:VCARD VERSION:3.0

X-UNKNOWN-ELEMENT;TYPE=objectclass:top
X-UNKNOWN-ELEMENT;TYPE=objectclass:person
X-UNKNOWN-ELEMENT;TYPE=objectclass:organizationalPerson
X-UNKNOWN-ELEMENT;TYPE=objectclass:inetOrgPerson
X-UNKNOWN-ELEMENT;TYPE=objectclass:mozillaAbPersonAlpha

I read over this How do I replace a newline in Atom? but none of the solutions there helped me find empty lines.

I wound up moving to bash to get rid of empty lines: sed -i '/^$/d' *.vcf but there are a bunch of other things I'd like to clean up. Stuff like:

X-UNKNOWN-ELEMENT;TYPE=E-mail 2 - Type:internet
X-UNKNOWN-ELEMENT;TYPE=E-mail 2 - Value:person@example.com

Which should become:

EMAIL;TYPE=WORK:person@example.com

That is just one example. There are others, they all revolve around matching multi-line strings, something I've never had a problem with before but in this case it just isn't finding the strings if I use the project search.

回答1:

Sigh.

The answer is: because Atom project search doesn't support multi-line searches, reg-ex or no:

https://github.com/atom/find-and-replace/issues/218