Replace any other instance of character per line

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

Post Reply
Glenn
Posts: 10
Joined: Wed Jan 23, 2013 8:54 pm

Replace any other instance of character per line

Post by Glenn » Wed Nov 28, 2018 12:03 am

Been a while since I fired this up..

Could anybody remind me of the best way to replace any other instance of a character (except for the first) per line please?

Bit of background: I have a 2 column CSV file that is semicolon delimited. I would like any other instance of a semicolon APART from the first instance replacing with a space.

Thank you.

DFH
Posts: 866
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Re: Replace any other instance of character per line

Post by DFH » Thu Dec 13, 2018 4:59 am

Use a PCRE pattern Restrict filter:

Code: Select all

Comment...
|  Replace all but the first semicolon on each line by a space
|
+--Perl pattern [^(.*;)(.+)$] and Send variable 2 to subfilter
   |  [X] Match case
   |  [ ] Whole words only
   |  [ ] Case sensitive replace
   |  [ ] Prompt on replace
   |  [ ] Skip prompt if identical
   |  [ ] First only
   |  [ ] Extract matches
   |      Maximum text buffer size 4096
   |  [ ] Maximum match (greedy)
   |  [ ] Allow comments
   |  [ ] '.' matches newline
   |  [X] UTF-8 Support
   |
   +--Replace [;] with [\x20]
         [X] Match case
         [ ] Whole words only
         [ ] Case sensitive replace
         [ ] Prompt on replace
         [ ] Skip prompt if identical
         [ ] First only
         [ ] Extract matches

         [ ] Process longest strings first
         [ ] Simultaneous search
         [ ] Log summary only
       
David
(a long time user of TextPipe)

Post Reply