user1882812
user1882812

Reputation: 946

Regex deleting everything between the first "," and "\n"

I want to delete everything between the two characters "," and "\n"

so for example this line:

@[@"Abend",@"evening",@"eve",@"even",@"eventide",@"time],

should become:

@[@"Abend",

How is this possible?

Also im searching for a possibility to make this line:

@[@"Abend",@"evening",@"eve",@"even",@"eventide",@"time],

to this line:

@"evening",

that means that just the first word between "@"" and ",@" should survie

Upvotes: 0

Views: 412

Answers (2)

Suvasish Sarker
Suvasish Sarker

Reputation: 435

This is how i did it, might be helpful :)

For first requirement:

^(.*?,).*$

For second requirement:

^@.*?,{1}(.*?,).*$

Upvotes: 0

sp00m
sp00m

Reputation: 48817

  1. Replace ^(.*?,).*$ by \1 (demo).
  2. Replace ^.*?,(.*?,).*$ by \1 (demo).

Screenshot

Upvotes: 1

Related Questions