10-20-2021, 05:03 PM | #1 |
Enthusiast
Posts: 30
Karma: 10
Join Date: Jul 2021
Device: Kindle Paperwhite, Kobo Libra 2
|
Search and Repace in comma separated list
Using Search and Replace, I am trying to clean up a custom column with pairings but I cannot manage to write the correct regex.
The input data is as follow: "A/B, C/D, E/F (mentioned), G/H (mentioned), I/J". The objective is to remove the pairing(s) which are only mentionned. I would like the following output: "A/B, C/D, IJ". I tried with this regex: Code:
,([^&]+)/([^&]+)\s\(mentioned\) How to write the regex so that commas are not included in the Code:
([^&]+) |
10-20-2021, 05:30 PM | #2 |
Well trained by Cats
Posts: 30,355
Karma: 58032210
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
remember ( are captures ), so they need to be escaped \( and \)
So try this (.+?),\w/\w\s*\(mentioned\),(.+?) Replace is \1,\2 NOT TESTED |
10-20-2021, 05:47 PM | #3 |
Enthusiast
Posts: 30
Karma: 10
Join Date: Jul 2021
Device: Kindle Paperwhite, Kobo Libra 2
|
Thank you, the \w was the key!
The final solution is: Code:
,\s\w+/\w+\s\(mentioned\) Last edited by Hortensia; 10-20-2021 at 06:14 PM. |
Tags |
regex, search and replace |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search and Save ONLY Book List | Vandy | Calibre | 1 | 01-18-2018 01:53 PM |
Custom column - Comma separated text | MerlinMama | Library Management | 4 | 09-17-2015 02:34 PM |
How do I repace a Style Sheet? | phossler | Editor | 13 | 12-24-2013 11:43 AM |
Multiple comma separated values in custom column? | silentguy | Library Management | 8 | 04-19-2011 05:10 AM |
Switching author name from comma separated to first last | kbaggs | Library Management | 1 | 01-30-2011 03:36 PM |