1

Given a pipe-delimited row:

ABC|123|pqr|cde|abc.txt|

I have to find 3rd pipe delimiter and remove the rest of the line.

Below is what the result should look like.

ABC|123|pqr|

How can I achieve this?

Jon Crowell
  • 21,695
  • 14
  • 89
  • 110

1 Answers1

3

Search using below regex and it will capture the first three pipes into group(1):

^(.+?\|.+?\|.+?\|).*

And then replace it with the captured group.

\1
Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
  • Yo Are simply Awesum...Another enhancement i want to do on it is like as soon as i remove the further text i want to add some text – user3443043 Mar 20 '14 at 18:51
  • 1
    @user3443043 You should have tried to figure it out, it's simple really. Just add what you want to add after `\1`... – Jerry Mar 20 '14 at 18:53