user743767
user743767

Reputation:

regex to remove text between two strings in TextWrangler

I've searched quite hard for an answer to this.

Basically, what I'm trying to do is to remove certain fields in some of my exported vCards which I exported using the Mac's Contacts application via Automator.

I managed to remove those single-line fields such as Birthday and Social Network. However, there is one particular field which is taking up multiple lines which I assume is a base64-encoded version of the original image - the PHOTO field.

This is an example of the start of the field: PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZJRgABAQAAAQABAAD/4gxYSUNDX1BST0ZJTEUA

The end varies, so I used the start of the next line as the end: CATEGORIES

The closest I've got was PHOTO;ENCODING.*CATEGORIES

Unfortunately, it seems to only select the the first line of the entire chunk.

Is there any way around this? I'm trying to do this in TextWrangler on my Mac.

Upvotes: 1

Views: 2584

Answers (2)

pdewost
pdewost

Reputation: 21

With the help of a friend I tried in TextWrangler

ATTACH;ENCODING=BASE64([^\n]*\n )*[^\n]*\n 

and it matches each attachment

Upvotes: 0

Himanshu
Himanshu

Reputation: 2454

Instead of .* you need :-

(.+[\r\n]+).*

because . doesn't match linebreak chars.

The pattern in parentheses matches multiple lines consisting of char sequences ending with linebreaks.

Upvotes: 1

Related Questions